欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來(lái)到入門(mén)教程網(wǎng)!

C語(yǔ)言

當(dāng)前位置:主頁(yè) > 軟件編程 > C語(yǔ)言 >

VC++ 自定義控件的建立及使用方法

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語(yǔ)言|點(diǎn)擊: 次

一、VC++定義自定義控件與delphi,VB有些差異。

delphi,vb在 file-new-other中建立。vc++在工具欄中就有自定義控件,但必須加入控件類(lèi)型。

許多書(shū)籍都在類(lèi)向?qū)е薪ⅰN疫@里介紹的是手動(dòng)建立,其結(jié)果是一樣的。

二.建立過(guò)自定義控件類(lèi)型:

   2.1、把工具欄上的自定義控件放入對(duì)話(huà)框中
   2.2、建立Mycontrol.h, Mycontrol.cpp文件
   2.3、Mycontrol.h中的定義是

#ifndef __MYCTROLTRL_H__
  #define __MYCTROLTRL_H__
  #define MYWNDCLASS "mycontrol"
  #include <afxtempl.h>
  class CMycontrol: public CWnd
  {
   private:
   public:
   static BOOL RegisterWndClass();
   CMycontrol();
   void customfun();//一個(gè)自定義方法
   };
  #endif

    2.4 Mycontrol.cpp中的實(shí)現(xiàn)部分

#include "StdAfx.h"
  #include "mycontrol.h"
  CMycontrol::CMycontrol()
  {
 CMycontrol::RegisterWndClass();
  }
  //注冊(cè)控件RegisterWndClass格式是固定的不要記憶沒(méi)有那個(gè)必要直接拷貝粘貼就可以。 
  CMycontrol::RegisterWndClass()
  {
  WNDCLASS windowclass;
  HINSTANCE hInst = AfxGetInstanceHandle();
  //Check weather the class is registerd already
  if (!(::GetClassInfo(hInst, MYWNDCLASS, &windowclass)))
  {
    //If not then we have to register the new class
    windowclass.style = CS_DBLCLKS;// | CS_HREDRAW | CS_VREDRAW;
    windowclass.lpfnWndProc = ::DefWindowProc;
    windowclass.cbClsExtra = windowclass.cbWndExtra = 0;
    windowclass.hInstance = hInst;
    windowclass.hIcon = NULL;
    windowclass.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
    windowclass.hbrBackground = ::GetSysColorBrush(COLOR_WINDOW);
    windowclass.lpszMenuName = NULL;
    windowclass.lpszClassName = MYWNDCLASS;
    if (!AfxRegisterClass(&windowclass))
    {
      AfxThrowResourceException();
      return FALSE;
    }
  } 
  return TRUE;
 }
 //自定義方法
 void CMycontrol::customfun()
 {
 AfxMessageBox(_T("my control!"));
 }

三、使用自定義控件

    3.1.在類(lèi)向?qū)е薪壎ㄗ远x控件時(shí)你是找不到剛才你定義的類(lèi)型的,所以我采用手動(dòng)加入代碼方法。
    3.2.在對(duì)話(huà)框.h文件中手動(dòng)加入:public: CMycontrol m_mycontrol;
    3.3.在對(duì)話(huà)框.cpp文件中手動(dòng)加入:DDX_Control(pDX,IDC_CUSTOM1,m_mycontrol);
    3.4.在對(duì)話(huà)框中加入Button 在點(diǎn)擊事件中加入測(cè)試代碼:

void CCustomcontrolDlg::OnButton1()
  {
 // TODO: Add your control notification handler code here
   m_mycontrol.customfun(); 
 }

四、編譯運(yùn)行vc++自定義控件的對(duì)話(huà)框窗體.編譯成功但運(yùn)行什么也不顯示的解決

右鍵自定義控件->屬性->類(lèi)型中填寫(xiě)"mycontrol"再次允許OK!

到此VC++自定義控件就全部介紹完畢,你可以在類(lèi)型中加入你要實(shí)現(xiàn)的方法。

以上所述就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡。

上一篇:C++中Cbitmap,HBitmap,Bitmap區(qū)別及聯(lián)系

欄    目:C語(yǔ)言

下一篇:c++學(xué)習(xí)之構(gòu)造函數(shù)

本文標(biāo)題:VC++ 自定義控件的建立及使用方法

本文地址:http://mengdiqiu.com.cn/a1/Cyuyan/3028.html

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有