怎样把unsigned long做为EDIT1->TEXT显示出来?

jas_liu 2003-10-18 01:47:57
要把unsigned long变为什么类型?
...全文
89 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fatwave 2003-10-18
  • 打赏
  • 举报
回复
强制转换
unsigned long lData;
Edit1->Text = AnsiString(lData);
ljianq 2003-10-18
  • 打赏
  • 举报
回复
直接Edit->Text=your_number;

typecheese12345 2003-10-18
  • 打赏
  • 举报
回复
For greater control over the formatting of the string, use the FloatToStrF function.the above answer is not true,sorry.
typecheese12345 2003-10-18
  • 打赏
  • 举报
回复
Edit->Text=LongToStr(your_number);
用c++如何获取本机ip? 其实这是一个很简单的程序,不多说,看代码 //------主程序--------------------------------------------------------------------- #include #pragma hdrstop #include "WINSOCK2.H" #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { struct hostent *thisHost; struct in_addr in; char MyName[80]; char *hostname,*ptr; //检测windows api 版本号 WORD wVerdionRequested; wVerdionRequested=MAKEWORD(2,0); WSADATA wsaData; int err; err=WSAStartup(wVerdionRequested,&wsaData;); if(err!=0) return; //对winsock api 初始化 if(LOBYTE(wsaData.wVersion)!=2||HIBYTE(wsaData.wVersion)!=0) { WSACleanup(); return; } //获取本机标准域名 if(gethostname(MyName,80)==SOCKET_ERROR) return; thisHost=gethostbyname(MyName); if(!thisHost) return; hostname=thisHost->h_name; //获取本机ip地址 memset((void *)∈,sizeof(in),0); in.s_addr=*((unsigned long *)thisHost->h_addr_list[0]); ptr=inet_ntoa(in); if(!ptr) return; //释放资源,输出结果 WSACleanup(); Edit1->Text=String(ptr); Edit2->Text=String(hostname); } //--------------------------------------------------------------------------- (全国大学生联盟 http://www.chinastlm.com 转载请保留此行) 请查看附件获取全部代码 获取本机ip.zip
// PhonePictureDlg.cpp : implementation file // #include "stdafx.h" #include "PhonePicture.h" #include "PhonePictureDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPhonePictureDlg dialog CPhonePictureDlg::CPhonePictureDlg(CWnd* pParent /*=NULL*/) : CDialog(CPhonePictureDlg::IDD, pParent) { //{{AFX_DATA_INIT(CPhonePictureDlg) m_PicWidth = 0; m_PicHigh = 0; m_address = _T(""); m_MouseX = 0; m_MouseY = 0; m_PicEditAdd = _T(""); //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CPhonePictureDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPhonePictureDlg) DDX_Control(pDX, IDC_COMBO1, m_buchang); DDX_Control(pDX, IDC_PICTYPE, m_pictype); DDX_Text(pDX, IDC_WIDTH, m_PicWidth); DDX_Text(pDX, IDC_HIGH, m_PicHigh); DDV_MinMaxInt(pDX, m_PicHigh, 0, 1000); DDX_Control(pDX, IDC_IMAGE1, m_image); DDX_Control(pDX, IDC_SCROLLBAR_Horizontal, m_HORScrollBar); DDX_Control(pDX, IDC_SCROLLBAR_Vertical, m_VERScrollBar); DDX_Text(pDX, IDC_ADDRESS, m_address); DDX_Control(pDX, IDC_SCROLLBAR_Horizontal2, m_width); DDX_Control(pDX, IDC_SCROLLBAR_Horizontal3, m_high); DDX_Text(pDX, IDC_EDIT1, m_MouseX); DDX_Text(pDX, IDC_EDIT2, m_MouseY); DDX_Control(pDX, IDC_SCROLLBAR_Horizontal4, m_PicNum); DDX_Text(pDX, IDC_EDIT3, m_PicEditAdd); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPhonePictureDlg, CDialog) //{{AFX_MSG_MAP(CPhonePictureDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_COMMAND(IDC_FILE_EXIT, OnFileExit) ON_EN_CHANGE(IDC_WIDTH, OnChangeWidth) ON_EN_CHANGE(IDC_HIGH, OnChangeHigh) ON_COMMAND(IDC_FILE_OPEN, OnFileOpen) ON_COMMAND(IDC_FILE_SAVE, OnFileSave) ON_COMMAND(IDC_FILE_SAVEAS, OnFileSaveas) ON_UPDATE_COMMAND_UI(IDC_FILE_SAVE, OnUpdateFileSave) ON_CBN_SELCHANGE(IDC_PICTYPE, OnSelchangePictype) ON_WM_TIMER() ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1) ON_EN_CHANGE(IDC_ADDRESS, OnChangeAddress) ON_COMMAND(IDC_PICTURE_EDITLAYOUT, OnPictureEditlayout) ON_COMMAND(IDC_PICTURE_EDITLAYIN, OnPictureEditlayin) ON_COMMAND(IDC_CUT, OnCut) ON_COMMAND(IDC_PASE, OnPase) ON_BN_CLICKED(IDC_RADIO1, OnRadio1) ON_BN_CLICKED(IDC_RADIO2, OnRadio2) ON_BN_CLICKED(IDC_RADIO3, OnRadio3) ON_BN_CLICKED(IDC_RADIO4, OnRadio4) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPhonePictureDlg message handlers BOOL CPhonePictureDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon CPoint point; // TODO: Add extra initialization here m_pictype.SetWindowText("16貫廬꽈"); PICTYPE=5; m_PicHigh=220; m_PicWidth=176; PicHigh=220; PicWidth=176; UpdateData(false); STEPX=STEPY=0; buchang=0; m_address="0x0"; m_width.SetMax(1560); m_width.SetValue(540); m_high.SetMax (560); m_high.SetValue(540); SelectPic=0; LoadRosoure(); fileready=0; needadd=0; STARTADD=0x9a47bc; needpack=0; return TRUE; } void CPhonePictureDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CPhonePictureDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(▭); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CPhonePictureDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CPhonePictureDlg::OnOK() { // TODO: Add extra validation here CDialog::OnOK(); } void CPhonePictureDlg::OnFileExit() { // TODO: Add your command handler code here OnOK() ; } BOOL CPhonePictureDlg::LoadRosoure() { HRSRC hRsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_BMPTITLE), TEXT("BIN")); if (NULL == hRsrc) return FALSE; //삿혤栗都돨댕鬼 DWORD dwSize = SizeofResource(NULL, hRsrc); if (0 == dwSize) return FALSE; //속潼栗都 HGLOBAL hGlobal = LoadResource(NULL, hRsrc); if (NULL == hGlobal) return FALSE; //傑땍栗都 LPVOID pBuffer = LockResource(hGlobal); if (NULL == pBuffer) return FALSE; else { BmpTitleBuf=(char*)pBuffer; BmpTitleSize=dwSize; } loadpictab(); return TRUE; } void CPhonePictureDlg::OnChangeWidth() { UpdateData(true); PicWidth=m_PicWidth; PicXNum=312/PicWidth; } void CPhonePictureDlg::OnChangeHigh() { UpdateData(true); PicHigh=m_PicHigh; PicYNum=258/PicHigh; } void CPhonePictureDlg::OnFileOpen() { char szFileFilter[]= "BIN File(*.Bin)|*.Bin|" "SKD File(*.SKD)|*.SKD|" "BMP File(*.BMP)|*.BMP|" "BMP File(*.DAT)|*.DAT|" "All File(*.*)|*.*|"; CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY,szFileFilter); if(dlg.DoModal()==IDOK) { FileName=dlg.GetPathName(); //뭐芚CFile뚤蹶 CFile File(FileName,CFile::modeRead); //롸토뻠녑혐,댕鬼槨匡숭댕鬼 FileSize=File.GetLength(); FileBuf = (char*) malloc(FileSize); File.ReadHuge(FileBuf,FileSize); File.Close(); m_HORScrollBar.SetMax(FileSize/65536) ; fileready=1; int k; switch(PICTYPE) { case 0: k=1; break; case 1: k=1; break; case 2: k=1; break; case 3: k=1; break; case 4: k=1; break; case 5: k=2; break; case 6: k=3; break; case 7: k=3; break; case 8: k=3; break; case 9: k=2; break; } m_VERScrollBar.SetMax(65536/k); SetTimeOn(50); } } void CPhonePictureDlg::OnFileSave() { // TODO: Add your command handler code here CFile File(FileName, CFile::modeCreate | CFile::modeWrite); File.WriteHuge(FileBuf,FileSize); File.Close(); } void CPhonePictureDlg::OnFileSaveas() { char szFileFilter[]= "BIN File(*.Bin)|*.Bin|" "SKD File(*.SKD)|*.SKD|" "All File(*.*)|*.*|"; CFileDialog SelectFile(FALSE,NULL,"",OFN_HIDEREADONLY,szFileFilter,NULL); SelectFile.m_ofn.lpstrTitle="朞嶝狼괏닸돨匡숭"; if(SelectFile.DoModal()==IDOK) { FileName=SelectFile.GetPathName(); CFile File(FileName, CFile::modeCreate | CFile::modeWrite); File.WriteHuge(FileBuf,FileSize); File.Close(); } } BEGIN_EVENTSINK_MAP(CPhonePictureDlg, CDialog) //{{AFX_EVENTSINK_MAP(CPhonePictureDlg) ON_EVENT(CPhonePictureDlg, IDC_IMAGE1, -607 /* MouseUp */, OnMouseUpImage1, VTS_I2 VTS_I2 VTS_R4 VTS_R4) ON_EVENT(CPhonePictureDlg, IDC_IMAGE1, -606 /* MouseMove */, OnMouseMoveImage1, VTS_I2 VTS_I2 VTS_R4 VTS_R4) ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal, 2 /* Change */, OnChangeSCROLLBARHorizontal, VTS_NONE) ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Vertical, 2 /* Change */, OnChangeSCROLLBARVertical, VTS_NONE) ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal, 7 /* Scroll */, OnScrollSCROLLBARHorizontal, VTS_NONE) ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Vertical, 7 /* Scroll */, OnScrollSCROLLBARVertical, VTS_NONE) ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal2, 2 /* Change */, OnChangeSCROLLBARHorizontal2, VTS_NONE) ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal2, 7 /* Scroll */, OnScrollSCROLLBARHorizontal2, VTS_NONE) ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal3, 2 /* Change */, OnChangeSCROLLBARHorizontal3, VTS_NONE) ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal3, 7 /* Scroll */, OnScrollSCROLLBARHorizontal3, VTS_NONE) ON_EVENT(CPhonePictureDlg, IDC_IMAGE1, -601 /* DblClick */, OnDblClickImage1, VTS_DISPATCH) ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal4, 2 /* Change */, OnChangeSCROLLBARHorizontal4, VTS_NONE) ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal4, 7 /* Scroll */, OnScrollSCROLLBARHorizontal4, VTS_NONE) ON_EVENT(CPhonePictureDlg, IDC_IMAGE1, 3 /* BeforeDragOver */, OnBeforeDragOverImage1, VTS_DISPATCH VTS_DISPATCH VTS_R4 VTS_R4 VTS_I4 VTS_DISPATCH VTS_I2) ON_EVENT(CPhonePictureDlg, IDC_SCROLLBAR_Horizontal2, 3 /* BeforeDragOver */, OnBeforeDragOverSCROLLBARHorizontal2, VTS_DISPATCH VTS_DISPATCH VTS_R4 VTS_R4 VTS_I4 VTS_DISPATCH VTS_I2) //}}AFX_EVENTSINK_MAP END_EVENTSINK_MAP() void CPhonePictureDlg::OnMouseUpImage1(short Button, short Shift, float X, float Y) { // TODO: Add your control notification handler code here if(Button==2&&fileready;==1) { CMenu *m_pMenu; CMenu menu; menu.LoadMenu(IDR_MAIN_MENU); m_pMenu = menu.GetSubMenu(1); m_pMenu->TrackPopupMenu(TPM_CENTERALIGN + TPM_LEFTBUTTON, int(X + 515),int(Y+450) ,this,NULL); } } void CPhonePictureDlg::OnUpdateFileSave(CCmdUI* pCmdUI) { } void CPhonePictureDlg::OnSelchangePictype() { PICTYPE=m_pictype.GetCurSel(); int k; switch(PICTYPE) { case 0: k=1; break; case 1: k=1; break; case 2: k=1; break; case 3: k=1; break; case 4: k=1; break; case 5: k=2; break; case 6: k=3; break; case 7: k=3; break; case 8: k=3; break; case 9: k=2; break; } m_VERScrollBar.SetMax(65536/k); } void CPhonePictureDlg::OnMouseMoveImage1(short Button, short Shift, float X, float Y) { MousePoint.x=int(X)*4/3; MousePoint.y=(int)Y*4/3; m_MouseX= MousePoint.x; m_MouseY= MousePoint.y; UpdateData(false); } void CPhonePictureDlg::OnChangeSCROLLBARHorizontal() { STEPX=m_HORScrollBar.GetValue(); } void CPhonePictureDlg::OnTimer(UINT nIDEvent) { ShowPic(); CDialog::OnTimer(nIDEvent); } void CPhonePictureDlg::SetTimeOn(int x) { int result=SetTimer(1,x,NULL); if(result==0) { MessageBox("땍珂포갛陋呵겨!."); } } void CPhonePictureDlg::ShowPic() { unsigned long add; add=STEPX*65536+STEPY+buchang; m_address=Hex2Str(add); UpdateData(false); switch(PICTYPE) { case 0: ShowMoneColor(PICTYPE); break; case 1: ShowMoneColor(PICTYPE); break; case 2: ShowMoneColorHH(); break; case 3: ShowMoneColorH(PICTYPE); break; case 4: Showcolor(8); break; case 5: Showcolor(16); break; case 6: Showcolor(24); break; case 7: Showcolor(32); break; case 8: Showcolor(22); break; case 9: Showcolor(12); break; } } void CPhonePictureDlg::Showcolor(int k)//鞫刻16貫꽈貫暠 { int i,j,p; unsigned short RGB; int w,h; unsigned long color; unsigned char R,G,B,H; CBitmap Bitmap,*pOldBitmap; int x,y; int pointnum; short pointcolor; x=MousePoint.x/PicWidth; y=MousePoint.y/PicHigh; BITMAP bm; CDC MemDC; CDC *pDC; unsigned char Data[499200]; PicXNum=1560/PicWidth; PicYNum=320/PicHigh; pDC=m_image.GetDC(); Bitmap.LoadBitmap(IDB_BITMAP1);// Bitmap.CreateBitmap(560,320,1,24,NULL);// //retrieve information about a CBitmap object Bitmap.GetObject(sizeof(BITMAP),&bm;); char *gadd; if(!MemDC.CreateCompatibleDC(pDC)) return ; pOldBitmap=(CBitmap*)MemDC.SelectObject(&Bitmap;); for(h=0;hFileSize) break; R=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+(PicWidth*PicHigh))+j*PicWidth+i); G=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+(PicWidth*PicHigh))+j*PicWidth+i); B=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+(PicWidth*PicHigh))+j*PicWidth+i); H=0; break; break; case 16: if(STEPX*65536+STEPY+buchang+(h*PicXNum+w)*2*(PicWidth*PicHigh)+2*j*PicWidth+2*i>FileSize) break; gadd=FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*2*(PicWidth*PicHigh)+2*j*PicWidth+2*i; RGB=*(unsigned short*)gadd; color= ConverColor16t24(RGB); if(x==w&&y==h&SelectPic;==1) { R=0xff-char((color&0x00ff0000;)>>16); G=0xff-char((color&0x0000ff00;)>>8); B=0xff-char(color&0x000000ff;); H=0; } else { B=char((color&0x00ff0000;)>>16); G=char((color&0x0000ff00;)>>8); R=char(color&0x000000ff;); H=0; } break; case 24: if(STEPX*65536+STEPY+buchang+(h*PicXNum+w)*3*(PicWidth*PicHigh)+3*j*PicWidth+3*i>FileSize) break; R=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+3*(PicWidth*PicHigh))+3*j*PicWidth+3*i); G=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+3*(PicWidth*PicHigh))+3*j*PicWidth+3*i+1); B=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+3*(PicWidth*PicHigh))+3*j*PicWidth+3*i+2); H=0; break; case 32: if(STEPX*65536+STEPY+buchang+(h*PicXNum+w)*4*(PicWidth*PicHigh)+4*j*PicWidth+4*i>FileSize) break; R=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+1); G=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+2); B=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+3); H=0;//*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+3); break; case 22: if(STEPX*65536+STEPY+buchang+(h*PicXNum+w)*4*(PicWidth*PicHigh)+4*j*PicWidth+4*i>FileSize) break; char tls,r,g,b; r=*(int*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+0); g=*(int*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+2); b=*(int*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i+3); color=*(int*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(8+4*(PicWidth*PicHigh))+4*j*PicWidth+4*i); tls=color&0x3; color=(color>>14)|(tls); R=(color>>12)*255/63; G=((color>>6)&0x3f;)*255/63; B=(color&0x3f;)*255/63; /* R= ((r<<4)|((g&0xf0;)>>4))*255/63; G= (((g&0x0f;)<<2)|((b&0xc0;)>>6))*255/63; B= (b&0x3f;)*255/63; */ H=0; break; case 12: if(STEPX*65536+STEPY+buchang+(h*PicXNum+w)*2*(PicWidth*PicHigh)+2*j*PicWidth+2*i>FileSize) break; gadd=FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*2*(PicWidth*PicHigh)+2*j*PicWidth+2*i; RGB=*(unsigned short*)gadd; color= ConverColor12t24(RGB); if(x==w&&y==h&SelectPic;==1) { B=0xff-char((color&0x00ff0000;)>>16); G=0xff-char((color&0x0000ff00;)>>8); R=0xff-char(color&0x000000ff;); H=0; } else { R=char((color&0x00ff0000;)>>16); G=char((color&0x0000ff00;)>>8); B=char(color&0x000000ff;); H=0; } break; } p=(h*PicHigh+j)*(bm.bmWidth)+w*PicWidth+i; Data[4*p]=B; Data[4*p+1]=G; Data[4*p+2]=R; Data[4*p+3]=H; } Bitmap.SetBitmapBits(bm.bmHeight*bm.bmWidthBytes ,Data); pDC->BitBlt(1,1,bm.bmWidth,bm.bmHeight,&MemDC;,0,0,SRCCOPY); MemDC.SelectObject(pOldBitmap); pDC->DeleteDC(); } unsigned long CPhonePictureDlg::ConverColor16t24(short D)//瘻뻣16貫槨24貫꽈 { int r,g,b; unsigned long color; if (D==0 || D==0xffff) return D; r=D&0xf800; r=r>>11; r=r*255/31; g=((D&0x7e0;)>>5)*255/63; b=(D&0x1f;)*255/31; color=b<<16|g<<8|r; return color; } void CPhonePictureDlg::OnChangeSCROLLBARVertical() { // TODO: Add your control notification handler code here int k; switch(PICTYPE) { case 0: k=1; break; case 1: k=1; break; case 2: k=1; break; case 3: k=1; break; case 4: k=1; break; case 5: k=2; break; case 6: k=3; break; case 7: k=4; break; case 8: k=2; break; case 9: k=2; } STEPY=k*m_VERScrollBar.GetValue(); } void CPhonePictureDlg::OnScrollSCROLLBARHorizontal() { // TODO: Add your control notification handler code here STEPX=m_HORScrollBar.GetValue(); } void CPhonePictureDlg::OnScrollSCROLLBARVertical() { // TODO: Add your control notification handler code here int k; switch(PICTYPE) { case 0: k=1; break; case 1: k=1; break; case 2: k=1; break; case 3: k=1; break; case 4: k=1; break; case 5: k=2; break; case 6: k=3; break; case 7: k=4; break; case 8: k=2; break; case 9: k=2; } STEPY=k*m_VERScrollBar.GetValue(); } CString CPhonePictureDlg::Hex2Str(unsigned long add) { char s; unsigned int i,h; CString retdata; retdata="0x"; if(add==0) return "0x0"; int k; for(i=0;i<8;i++) { h=add<<(i*4); h=h>>28; s=ConvertHex2Char(h); if(s!=0x30||k==1 ) { retdata+=s; k=1; } } return retdata; } char CPhonePictureDlg::ConvertHex2Char(int hex) { char retdata; switch(hex) { case 0: retdata='0'; break; case 1: retdata='1'; break; case 2: retdata='2'; break; case 3: retdata='3'; break; case 4: retdata='4'; break; case 5: retdata='5'; break; case 6: retdata='6'; break; case 7: retdata='7'; break; case 8: retdata='8'; break; case 9: retdata='9'; break; case 10: retdata='A'; break; case 11: retdata='B'; break; case 12: retdata='C'; break; case 13: retdata='D'; break; case 14: retdata='E'; break; case 15: retdata='F'; break; } return retdata; } void CPhonePictureDlg::OnSelchangeCombo1() { // TODO: Add your control notification handler code here buchang=m_buchang.GetCurSel(); } void CPhonePictureDlg::OnChangeAddress() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here KillTimer(1); CString data; UpdateData(true); data=m_address; long address=Str2Hex(data); STEPX=address/65536; STEPY=(addresse536); //m_VERScrollBar.SetValue(STEPY); // OnScrollSCROLLBARVertical(); SetTimeOn(50); } unsigned long CPhonePictureDlg::Str2Hex(CString address) { unsigned long returndata; int len,i,k,h; len=address.GetLength(); CString s; char d; k=0; returndata=0; if(len>2) { s=address[0]; s+=address[1]; if(s=="0x"|s=="0X") for(i=2;i='0')&&(ch<='9')) return ch-0x30; else if((ch>='A')&&(ch<='F')) return ch-'A'+10; else if((ch>='a')&&(ch<='f')) return ch-'a'+10; else return (-1); } void CPhonePictureDlg::PreSubclassWindow() { // TODO: Add your specialized code here and/or call the base class CDialog::PreSubclassWindow(); } void CPhonePictureDlg::ShowMoneColor(int k) { int i,j,p; char RGB; int w,h; unsigned char R,G,B; CBitmap Bitmap,*pOldBitmap; BITMAP bm; CDC MemDC; CDC *pDC; unsigned char Data[499200]; PicXNum=560/(8*PicWidth); PicYNum=320/PicHigh; pDC=m_image.GetDC(); Bitmap.LoadBitmap(IDB_BITMAP1);// Bitmap.CreateBitmap(560,320,1,24,NULL);// //retrieve information about a CBitmap object Bitmap.GetObject(sizeof(BITMAP),&bm;); if(!MemDC.CreateCompatibleDC(pDC)) return ; pOldBitmap=(CBitmap*)MemDC.SelectObject(&Bitmap;); long picwidth=bm.bmWidth; for(h=0;hFileSize) return; RGB=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(PicWidth*PicHigh)+PicWidth*j+i); for(int m=0;m<8;m++) { R=RGB>>7-m; R=R&0x1; if(R ) { B=0; G=0; R=0; } else { B=255; G=255; R=255; } p=(h*PicHigh+j)*(picwidth)+8*w*PicWidth+8*i+m; Data[4*p]=B; Data[4*p+1]=G; Data[4*p+2]=R; Data[4*p+3]=0; } } Bitmap.SetBitmapBits(bm.bmHeight*bm.bmWidthBytes ,Data); pDC->BitBlt(1,1,bm.bmWidth,bm.bmHeight,&MemDC;,0,0,SRCCOPY); MemDC.SelectObject(pOldBitmap); pDC->DeleteDC(); } void CPhonePictureDlg::ShowMoneColorHH() { int i,j,p; unsigned char RGB; int w,h; unsigned char R,G,B; CBitmap Bitmap,*pOldBitmap; BITMAP bm; CDC MemDC; CDC *pDC; unsigned char Data[499200]; PicXNum=560/(PicWidth); PicYNum=320/(8*PicHigh); pDC=m_image.GetDC(); Bitmap.LoadBitmap(IDB_BITMAP1);// Bitmap.CreateBitmap(560,320,1,24,NULL);// //retrieve information about a CBitmap object Bitmap.GetObject(sizeof(BITMAP),&bm;); if(!MemDC.CreateCompatibleDC(pDC)) return ; pOldBitmap=(CBitmap*)MemDC.SelectObject(&Bitmap;); long picwidth=bm.bmWidth; for(h=0;hFileSize) return; RGB=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(PicWidth*PicHigh)+PicWidth*j+i); for(int m=0;m<8;m++) { R=RGB>>7-m; R=R&0x1; if(R ) { B=0; G=0; R=0; } else { B=255; G=255; R=255; } p=(h*PicHigh*8+j*8+7-m)*picwidth+w*PicWidth+i; Data[4*p]=B; Data[4*p+1]=G; Data[4*p+2]=R; Data[4*p+3]=0; } } Bitmap.SetBitmapBits(bm.bmHeight*bm.bmWidthBytes ,Data); pDC->BitBlt(1,1,bm.bmWidth,bm.bmHeight,&MemDC;,0,0,SRCCOPY); MemDC.SelectObject(pOldBitmap); pDC->DeleteDC(); } void CPhonePictureDlg::ShowMoneColorH(int k) { int i,j,p; char RGB; int w,h; unsigned char R,G,B; CBitmap Bitmap,*pOldBitmap; BITMAP bm; CDC MemDC; CDC *pDC; unsigned char Data[499200]; PicXNum=560/(PicWidth); PicYNum=320/(8*PicHigh); pDC=m_image.GetDC(); Bitmap.LoadBitmap(IDB_BITMAP1);// Bitmap.CreateBitmap(560,320,1,24,NULL);// //retrieve information about a CBitmap object Bitmap.GetObject(sizeof(BITMAP),&bm;); if(!MemDC.CreateCompatibleDC(pDC)) return ; pOldBitmap=(CBitmap*)MemDC.SelectObject(&Bitmap;); long picwidth=bm.bmWidth; for(h=0;hFileSize) return; RGB=*(unsigned char*)(FileBuf+buchang+STEPX*65536+STEPY+(h*PicXNum+w)*(PicWidth*PicHigh)+PicHigh*j+i); for(int m=0;m<8;m++) { R=RGB>>7-m; R=R&0x1; if(R ) { B=0; G=0; R=0; } else { B=255; G=255; R=255; } p=(8*h*PicHigh+8*i+7-m)*(picwidth)+w*PicWidth+j; Data[4*p]=B; Data[4*p+1]=G; Data[4*p+2]=R; Data[4*p+3]=0; } } Bitmap.SetBitmapBits(bm.bmHeight*bm.bmWidthBytes ,Data); pDC->BitBlt(1,1,bm.bmWidth,bm.bmHeight,&MemDC;,0,0,SRCCOPY); MemDC.SelectObject(pOldBitmap); pDC->DeleteDC(); } //DEL void CPhonePictureDlg::OnCustomdrawSlider1(NMHDR* pNMHDR, LRESULT* pResult) //DEL { //DEL // TODO: Add your control notification handler code here //DEL PicWidth=m_slid.GetPos(); //DEL *pResult = 0; //DEL } void CPhonePictureDlg::OnChangeSCROLLBARHorizontal2() { // TODO: Add your control notification handler code here PicWidth=m_width.GetValue()+1; m_PicWidth=PicWidth; UpdateData(false); } void CPhonePictureDlg::OnScrollSCROLLBARHorizontal2() { // TODO: Add your control notification handler code here PicWidth=m_width.GetValue()+1; m_PicWidth=PicWidth; UpdateData(false); } void CPhonePictureDlg::OnChangeSCROLLBARHorizontal3() { // TODO: Add your control notification handler code here PicHigh=m_high.GetValue()+1; m_PicHigh=PicHigh; UpdateData(false); } void CPhonePictureDlg::OnScrollSCROLLBARHorizontal3() { // TODO: Add your control notification handler code here PicHigh=m_high.GetValue()+1; m_PicHigh=PicHigh; UpdateData(false); } void CPhonePictureDlg::OnDblClickImage1(LPDISPATCH Cancel) { SelectPic++; if(SelectPic==2) SelectPic=0; } void CPhonePictureDlg::OnPictureEditlayout() { int x,y,numx,numy; char R,G,B; char *temp; numx=560/(PicWidth); numy=320/PicHigh; x=MousePoint.x/PicWidth; y=MousePoint.y/PicHigh; long Size; unsigned long color,TLS; unsigned short RGB; int k; switch(PICTYPE) { case 4: k=1; break; case 5: k=2; break; case 6: k=3; break; case 7: k=1; break; case 8: k=18; break; case 9: k=3; break; } Size=PicWidth*PicHigh*k; if(k!=1) { temp=(char*)malloc((PicWidth*3+4-PicWidth*3%4)*PicHigh+0x50); *(long*)(BmpTitleBuf+0x12)=PicWidth; *(long*)(BmpTitleBuf+0x16)=PicHigh; memcpy(temp,BmpTitleBuf,54); } if(k==3) { memcpy(temp+54,FileBuf+STEPX*65536+STEPY+buchang+(y*numx+x)*Size,Size); } if(k==4) { memcpy(temp+54,FileBuf+STEPX*65536+STEPY+buchang+(y*numx+x)*Size,Size); } if(k==2) { Size=PicWidth*PicHigh; for(int j=0;j>16); G=char((color&0x0000ff00;)>>8); R=char(color&0x000000ff;); if(PicWidth*3%4!=0) { *(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3)=B; *(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3+1)=G; *(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3+2)=R; } else {*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3)=B; *(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3+1)=G; *(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3+2)=R; } } if(PicWidth*3%4!=0) Size=(PicWidth*3+4-PicWidth*3%4)*PicHigh; else Size=(PicWidth*3)*PicHigh; } if(k==18) { Size=4*PicWidth*PicHigh; for(int j=0;junsigned long*)(FileBuf+STEPX*65536+STEPY+buchang+(y*numx+x)*Size+(i+j*PicWidth)*4); color= ConverColor18t24(TLS); B=char((color&0x00ff0000;)>>16); G=char((color&0x0000ff00;)>>8); R=char(color&0x000000ff;); if(PicWidth*3%4!=0) { *(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3)=B; *(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3+1)=G; *(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3+4-PicWidth*3%4)+i*3+2)=R; } else {*(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3)=B; *(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3+1)=G; *(char*)(temp+54+(PicHigh-j-1)*(PicWidth*3 )+i*3+2)=R; } } if(PicWidth*3%4!=0) Size=(PicWidth*3+4-PicWidth*3%4)*PicHigh; else Size=(PicWidth*3)*PicHigh; } if(k==1) { if(PicWidth%4!=0) Size=PicHigh*(PicWidth+4-PicWidth%4)+1078; else Size=PicHigh*(PicWidth)+1078; temp=(char*)malloc(Size); memcpy(temp,BmpTitleBuf+54,1078); *(long*)(temp+0x12)=PicWidth; *(long*)(temp+0x16)=PicHigh; *(long*)(temp+2)=Size; if(PicWidth%4!=0) for(int j=0;jEditlayin() { int x,y,numx,numy; unsigned char R,G,B; long leng; char *temp,*tempadd; CString Name; long templen; numx=560/(PicWidth); numy=320/PicHigh; x=MousePoint.x/PicWidth; y=MousePoint.y/PicHigh; long Size; int k; switch(PICTYPE) { case 4: k=1; break; case 5: k=2; break; case 6: k=3; break; case 7: k=1; break; case 8: k=18; break; case 9: k=3; break; } char szFileFilter[]= "BMP File(*.BMP)|*.BMP|" "All File(*.*)|*.*|"; CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY,szFileFilter); if(dlg.DoModal()==IDOK) { Name=dlg.GetPathName(); if(Name=="") return; CFile File(Name,CFile::modeRead); templen=File.GetLength(); temp = (char*) malloc(templen); File.ReadHuge(temp,templen); File.Close(); } if(Name=="") return; if(*(int*)(temp+0x12)!=PicWidth||*(int*)(temp+0x16)!=PicHigh) { MessageBox("暠튬댕鬼꼇宮륜!"); return ; } if(k==3) { Size=PicHigh*PicWidth*k; memcpy(FileBuf+STEPX*65536+STEPY+buchang+(y*numx+x)*Size,temp+54,Size); } if(k==2) { Size=PicWidth*PicHigh; if(needadd==1) { *(short*)( FileBuf+STEPX*65536+STEPY+buchang+(y*numx+x)*k*Size)=PicWidth; *(short*)( FileBuf+STEPX*65536+STEPY+buchang+(y*numx+x)*k*Size+2)=PicHigh; } if(needpack==0) for(int j=0;jlong*)(FileBuf+STARTADD+m_PicNum.GetValue()*4)=STEPX*65536+STEPY+buchang+(y*numx+x)*k*Size; if(needpack==1) STEPY+=leng+4; } if(k==18) { for(int j=0;junsigned char*)(tempadd); G=*(unsigned char*)(tempadd+1); R=*(unsigned char*)(tempadd+2); unsigned long color= ConverColor24t18(R,G,B); *(unsigned long*)(FileBuf+STEPX*65536+STEPY+buchang+(y*numx+x)*k*Size+4*(j*PicWidth+i))=color; } } } if(k==1) { if(PicWidth%4!=0) { for(int j=0;junsigned char R,unsigned char G,unsigned char B) { short color; float x; x=(float)R*31/255; x+=0.5; R=(char)x; x=(float)G*63; x=x/255; G=(char)x; x=(float)B*31; x=x/255; B=(char)x; color=R<<11; color+=+G<<5; color+=B; return color; } void CPhonePictureDlg::OnCut() { int x,y,numx,numy; numx=560/(PicWidth); numy=320/PicHigh; x=MousePoint.x/PicWidth; y=MousePoint.y/PicHigh; long Size; int k; switch(PICTYPE) { case 5: k=2; break; case 6: k=3; break; } Size=PicWidth*PicHigh*k; PicCutTempBuf=(char*)malloc(Size); for(int i=0;ilong*)(FileBuf+STEPX*65536+STEPY+buchang+(y*numx+x)*Size+Nouse.GetLength()+1)=Size; *(char*)(FileBuf+STEPX*65536+STEPY+buchang+(y*numx+x)*Size+Nouse.GetLength())=0; PicOldAddress=STEPX*65536+STEPY+buchang+(y*numx+x)*Size; PicCut=1; } void CPhonePictureDlg::OnPase() { int x,y,numx,numy; numx=560/(PicWidth); numy=320/PicHigh; x=MousePoint.x/PicWidth; y=MousePoint.y/PicHigh; long Size; int k; if(PicCut!=1) return; switch(PICTYPE) { case 5: k=2; break; case 6: k=3; break; } Size=PicWidth*PicHigh*k; long NewAddress=STEPX*65536+STEPY+buchang+(y*numx+x)*Size; int Count=SearchAddress(PicOldAddress,NewAddress); if(Count==0) { AfxMessageBox("匡숭櫓청唐冷돕늪뒈囹寧濾,늪暠튬옵콘청唐賈痰"); return; } for(int i=0;ilong address,long address1) { int count; count=0; for(int i=0;ilong*)(FileBuf+i)!=address) continue; *(long*)(FileBuf+i)=address1; count++; } return count; } BOOL CPhonePictureDlg::loadpictab() { /* HRSRC hRsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_PICTAB), TEXT("BIN")); if (NULL == hRsrc) return FALSE; //삿혤栗都돨댕鬼 DWORD dwSize = SizeofResource(NULL, hRsrc); if (0 == dwSize) return FALSE; //속潼栗都 HGLOBAL hGlobal = LoadResource(NULL, hRsrc); if (NULL == hGlobal) return FALSE; //傑땍栗都 LPVOID puffer = LockResource(hGlobal); if (NULL == puffer) return FALSE; else { TabBuf=(char*)puffer; TabLen=dwSize; } */ return TRUE; char szFileFilter[]= "BIN File(*.Bin)|*.Bin|" "SKD File(*.SKD)|*.SKD|" "BMP File(*.BMP)|*.BMP|" "All File(*.*)|*.*|"; CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY,szFileFilter); if(dlg.DoModal()==IDOK) { FileName=dlg.GetPathName(); CFile File(FileName,CFile::modeRead); TabLen=File.GetLength(); TabBuf=(char*) malloc(TabLen); File.ReadHuge(TabBuf,TabLen); File.Close(); m_PicNum.SetMax(TabLen/4); } return TRUE; } void CPhonePictureDlg::OnChangeSCROLLBARHorizontal4() { int k; if(needadd!=0) { k=m_PicNum.GetValue(); PicEditAdd=*(long*)(TabBuf+k*4); m_PicEditAdd=Hex2Str(PicEditAdd); PicWidth=*(unsigned short*)(FileBuf+PicEditAdd); PicHigh=*(unsigned short*)(FileBuf+PicEditAdd+2); m_PicWidth=PicWidth; m_PicHigh=PicHigh; UpdateData(false); } else STEPY+=PicWidth*PicHigh*2; } void CPhonePictureDlg::OnScrollSCROLLBARHorizontal4() { int k; if(needadd!=0) { k=m_PicNum.GetValue(); PicEditAdd=*(long*)(TabBuf+k*4); m_PicEditAdd=Hex2Str(PicEditAdd); PicWidth=*(unsigned short*)(FileBuf+PicEditAdd); PicHigh=*(unsigned short*)(FileBuf+PicEditAdd+2); m_PicWidth=PicWidth; m_PicHigh=PicHigh; UpdateData(false); } else STEPY+=PicWidth*PicHigh*2; } void CPhonePictureDlg::OnRadio1() { needadd=1; } void CPhonePictureDlg::OnRadio2() { // TODO: Add your control notification handler code here needadd=0; } void CPhonePictureDlg::OnRadio3() { // TODO: Add your control notification handler code here needpack=1; } void CPhonePictureDlg::OnRadio4() { // TODO: Add your control notification handler code here needpack=0; } long CPhonePictureDlg::packbmp(char *buf,long len) { char *pbuf,*tempadd; int x,y,num; unsigned char R,G,B; short tempdata; len=2*PicHigh*PicWidth; pbuf=(char*)malloc(len); for(int j=0;jlong pos,pos1; pos=0; pos1=0; num=0; tempdata=*(short*)(pbuf); num++; for(x=1;xunsigned long CPhonePictureDlg::ConverColor12t24(short D) { int r,g,b; unsigned long color; if (D==0 || D==0xfff) return D; r=D&0xf00; r=r>>8; r=r*255/16; g=((D&0xf0;)>>4)*255/16; b=(D&0xf;)*255/16; color=b<<16|g<<8|r; return color; } unsigned long CPhonePictureDlg::ConverColor18t24(unsigned long color) { int r,g,b; unsigned long D; D=color&0x3ffff; if (D==0) return D; if(D==0X3FFFF) return 0xffffff; r=D&0x3f000; r=r>>12; r=r*255/63; g=((D&0xfc0;)>>6)*255/63; b=(D&0x3f;)*255/63; color=b<<16|g<<8|r; return color; } unsigned long CPhonePictureDlg::ConverColor24t18(unsigned char R, unsigned char G, unsigned char B) { unsigned long color; float x; color=0; R=R*63/255; G=G*63/255; B=B*63/255; color=R<<12|G<<6|B; return color; } void CPhonePictureDlg::OnBeforeDragOverImage1(LPDISPATCH Cancel, LPDISPATCH Data, float X, float Y, long DragState, LPDISPATCH Effect, short Shift) { // TODO: Add your control notification handler code here } void CPhonePictureDlg::OnBeforeDragOverSCROLLBARHorizontal2(LPDISPATCH Cancel, LPDISPATCH Data, float X, float Y, long DragState, LPDISPATCH Effect, short Shift) { // TODO: Add your control notification handler code here }
1 , Manager.zipThis has assorted functions (file copy, time, settings, etc).2 , manc-html.zipAn example I did to retreive an Email Address or URL from an HTML file.3 , basFile.zipThis bas file is filled with assorted file related functions. If you work with file manipulation, then you should take a look at this.4 , dragdropfiles.zipThis example shows how you can support drag and drop functionality to your application in the form of images5 , assoc.zipThis example demonstrates how to edit the registry so your application is associated with a certain file extension.6 , watchdir.zipThis demonstrates how to watch a specific directory for any changes. An excellent idea for an Anti-Virus/Security program.7 , dellines.zip"Open the file and use Line Input to read lines. Write any that do not contain the target into a temporary file. Use Kill to remove the original file and then use Name to give the temporary file the old file name."8 , cpyfile.zipThis will copy a specified file to a directory. It also shows its progress through a Progress Bar.9 , cshort.zipThis demonstrates how to create a short-cut to a specific file. 10 , fsize.zipThis demonstrates how to retrieve the file size from a specified file.11 , cleardocs.zipThis will clear the documents on the Start Menu.12 , syscolor.zipThis is an example of how to retrieve the system colors and display them on your form.13 , findfiles.zipThis is an example of how to return all of the files on a users system. This can be easily edited to be close to the normal Windows' Find File or Folder Dialog.14 , Sorter13.zipAn updated version of The Sorter. Now you choose the file to save. Also, it can handle up to 1 MB now.15 , coolExplorer.zipA cool program that has the most basic functions of a windows explorer: Delete, Copy , Move... file viewing and
sdk LCS/Telegraphics Wintab* Interface Specification 1.1: 16- and 32-bit API Reference By Rick Poyner Revised February 11, 2012 This specification was developed in response to a perceived need for a standardized programming inter-face to digitizing tablets, three dimensional position sensors, and other pointing devices by a group of lead-ing digitizer manufacturers and applications developers. The availability of drivers that support the features of the specification will simplify the process of developing Windows appli¬cation programs that in-corporate absolute coordinate input, and enhance the acceptance of ad¬vanced pointing de¬vices among users. This specification is intended to be an open standard, and as such the text and information contained herein may be freely used, copied, or distributed without compensation or licensing restrictions. This document is copyright 1991-2012 by LCS/Telegraphics.* Address questions and comments to: LCS/Telegraphics 150 Rogers St. Cambridge, MA 02142 (617)225-7970 (617)225-7969 FAX Compuserve: 76506,1676 Internet: wintab@pointing.com Note: sections marked with the “(1.1)” are new sections added for specification version 1.1. Sec-tions bearing the “(1.1 modified)” notation contain updated information for specification version 1.1. Version 1.1 Update Notation Conventions 1 1. Background Information 1 1.1. Features of Digitizers 1 1.2. The Windows Environment 1 2. Design Goals 2 2.1. User Control 2 2.2. Ease of Programming 2 2.3. Tablet Sharing 3 2.4. Tablet Feature Support 3 3. Design Concepts 3 3.1. Device Conventions 3 3.2. Device Information 4 3.3. Tablet Contexts 4 3.4. Event Packets 4 3.5. Tablet Managers 5 3.6. Extensions 5 3.7. Persistent Binding of Interface Features (1.1) 6 4. Interface Implementations 6 4.1. File and Module Conventions 6 4.2. Feature Support Options 6 5. Function Reference 7 5.1. Basic Functions 7 5.1.1. WTInfo 8 5.1.2. WTOpen 9 5.1.3. WTClose 10 5.1.4. WTPacketsGet 10 5.1.5. WTPacket 11 5.2. Visibility Functions 11 5.2.1. WTEnable 11 5.2.2. WTOverlap 12 5.3. Context Editing Functions 12 5.3.1. WTConfig 12 5.3.2. WTGet 13 5.3.3. WTSet (1.1 modified) 13 5.3.4. WTExtGet 14 5.3.5. WTExtSet 14 5.3.6. WTSave 15 5.3.7. WTRestore 15 5.4. Advanced Packet and Queue Functions 16 5.4.1. WTPacketsPeek 16 5.4.2. WTDataGet 17 5.4.3. WTDataPeek 17 5.4.4. WTQueuePackets (16-bit only) 18 5.4.5. WTQueuePacketsEx 18 5.4.6. WTQueueSizeGet 19 5.4.7. WTQueueSizeSet 19 5.5. Manager Handle Functions 19 5.5.1. WTMgrOpen 19 5.5.2. WTMgrClose 20 5.6. Manager Context Functions 20 5.6.1. WTMgrContextEnum 20 5.6.2. WTMgrContextOwner 21 5.6.3. WTMgrDefContext 22 5.6.4. WTMgrDefContextEx (1.1) 22 5.7. Manager Configuration Functions 23 5.7.1. WTMgrDeviceConfig 23 5.7.2. WTMgrConfigReplace (16-bit only) 24 5.7.3. WTMgrConfigReplaceEx 24 5.8. Manager Packet Hook Functions 25 5.8.1. WTMgrPacketHook (16-bit only) 26 5.8.2. WTMgrPacketHookEx 26 5.8.3. WTMgrPacketUnhook 29 5.8.4. WTMgrPacketHookDefProc (16-bit only) 30 5.8.5. WTMgrPacketHookNext 30 5.9. Manager Preference Data Functions 31 5.9.1. WTMgrExt 31 5.9.2. WTMgrCsrEnable 32 5.9.3. WTMgrCsrButtonMap 32 5.9.4. WTMgrCsrPressureBtnMarks (16-bit only) 33 5.9.5. WTMgrCsrPressureBtnMarksEx 33 5.9.6. WTMgrCsrPressureResponse 34 5.9.7. WTMgrCsrExt 35 6. Message Reference 36 6.1. Event Messages 36 6.1.1. WT_PACKET 36 6.1.2. WT_CSRCHANGE (1.1) 37 6.2. Context Messages 37 6.2.1. WT_CTXOPEN 37 6.2.2. WT_CTXCLOSE 37 6.2.3. WT_CTXUPDATE 38 6.2.4. WT_CTXOVERLAP 38 6.2.5. WT_PROXIMITY 38 6.3. Information Change Messages 39 6.3.1. WT_INFOCHANGE 39 7. Data Reference 39 7.1. Common Data Types (1.1 modified) 39 7.2. Information Data Structures 41 7.2.1. AXIS 41 7.2.2. Information Categories and Indices (1.1 modified) 42 7.3. Context Data Structures 50 7.3.1. LOGCONTEXT (1.1 modified) 50 7.4. Event Data Structures 55 7.4.1. PACKET (1.1 modified) 55 7.4.2. ORIENTATION 57 7.4.3. ROTATION (1.1) 58 Appendix A. Using PKTDEF.H 59 Appendix B. Extension Definitions 60 B.1. Extensions Programming 60 B.2. Out of Bounds Tracking 61 OBT Programming 61 Information Category 61 Turning OBT On and Off 61 B.3. Function Keys 62 FKEYS Programming 62 Information Category 62 B.4. Tilt 62 TILT Programming 63 Information Category 63 B.5. Cursor Mask 63 CSRMASK Programming 64 Information Category 64 B.6. Extended Button Masks 64 XBTNMASK Programming 64 Information Category 65 VERSION 1.1 UPDATE NOTATION CONVENTIONS Sections marked with the “(1.1)” are new sections added for specification version 1.1. Sections bearing the “(1.1 modified)” notation contain updated information for specification version 1.1. The “(1.1)” notation also marks the definitions of new functions, messages, and data structures. The nota-tion “1.1:” marks new text or commentaries explaining new functionality added to existing features. 1 BACKGROUND INFORMATION This document describes a programming interface for using digitizing tablets and other advanced pointing de¬vices with Microsoft Windows Version 3.0 and above. The design presented here is based on the input of numerous professionals from the pointing device manufacturing and Windows soft¬ware development industries. In this document, the words "tablet" and "digitizer" are used interchange¬ably to mean all absolute point¬ing or digitizing devices that can be made to work with this interface. The definition is not lim¬ited to de¬vices that use a physical tablet. In fact, this specification can support de¬vices that combine rela¬tive and absolute pointing as well as purely relative devices. The following sections describe features of tablets and of the Windows environment that helped mo¬tivate the design. 1.1 Features of Digitizers Digitizing tablets present several problems to device interface authors. • Many tablets have a very high report rate. • Many tablets have many configurable features and types of input information. • Tablets often control the system cursor, provide additional digitizing input, and provide template or macro functions. 1.2 The Windows Environment Programming for tablets in the Windows environment presents additional problems. • Multitasking means multiple applications may have to share the tablet. • The tablet must also be able to control the system cursor and/or the pen (in Pen Windows). • The tablet must work with legacy applications, and with applications written to take advan¬tage of tablet services. • The tablet driver must add minimal speed and memory overhead, so as many applications as possible can run as efficiently as possible. • The user should be able to control how applications use the tablet. The user interface must be ef-ficient, consistent, and customizable. 2 DESIGN GOALS While the tablet interface design must address the technical problems stated above, it must also be useful to the programmers who will write tablet programs, and ultimately, to the tablet users. Four design goals will help clarify these needs, and provide some criteria for evaluating the interface speci¬fication. The goals are user control, ease of programming, tablet sharing, and tablet feature support. 2.1 User Control The user should be able to use and control the tablet in as natural and easy a manner as possible. The user's preferences should take precedence over application requests, where possible. Here are questions to ask when thinking about user control as a design goal: • Can the user understand how applications use the tablet? • Is the interface for controlling tablet functions natural and unobtrusive? • Is the user allowed to change things that help to customize the work environment, but pre¬vented from changing things over which applications must have control? 2.2 Ease of Programming Programming is easiest when the amount of knowledge and effort required matches the task at hand. Writing simple programs should require only a few lines of code and a minimal understanding of the en-vironment. On the other hand, more advanced features and functions should be available to those who need them. The interface should accommodate three kinds of programmers: those who wish to write sim-ple tablet programs, programmers who wish to write complex applications that take full ad¬vantage of tab-let capabilities, and programmers who wish to provide tablet device control features. In addition, the inter-face should accommodate programmers in as many different programming lan¬guages, situations, and en-vironments as possible. Questions to ask when thinking about ease of programming include: • How hard is it to learn the interface and write a simple program that uses tablet input? • Can programmers of complex applications control the features they need? • Are more powerful tablet device control features available? • Can the interface be used in different programming environments? • Is the interface logical, consistent, and robust? 2.3 Tablet Sharing In the Windows environment, multiple applications that use the tablet may be running at once. Each ap-plication will require different services. Applications must be able to get the services they need without getting in each others' way. Questions to ask when thinking about tablet sharing include: • Can tablet applications use the tablet features they need, independent of other applications? • Does the interface prevent a rogue application from "hijacking" the tablet, or causing dead¬locks? • Does the sharing architecture promote efficiency? 2.4 Tablet Feature Support The interface gives standard access to as many features as possible, while leaving room for future ex¬ten-sions and vendor-specific customizations. Applications should be able to get the tablet informa¬tion and services they want, just the way they want them. Users should be able to use the tablet to set up an effi-cient, comfortable work environment. Questions to ask when thinking about tablet feature support include: • Does the interface provide the features applications need? Are any commonly available fea¬tures not supported? • Does the interface provide what users need? Is anything missing? • Are future extensions possible and fairly easy? • Are vendor-specific extensions possible? 3 DESIGN CONCEPTS The proposed interface design depends on several fundamental concepts. Devices and cursor types de-scribe physical hardware configurations. The interface publishes read-only information through a single information interface. Applications interact with the interface by setting up tablet contexts and consuming event packets. Applications may assume interface and hardware control functions by be¬coming tablet managers. The interface provides explicit support for future extensions. 3.1 Device Conventions The interface provides access to one or more devices that produce pointing input. Devices sup¬ported by this interface have some common characteristics. The device must define an absolute or relative coordi-nate space in at least two dimensions for which it can return position data. The device must have a point-ing ap¬para¬tus or method (such as a stylus, or a finger touching a touch pad), called the cursor, that de¬fines the current position. The cursor must be able to return at least one bit of additional state (via a but¬ton, touching a digitizing surface, etc.). Devices may have multiple cursor types that have different physical configurations, or that have differ¬ent numbers of buttons, or return auxiliary information, such as pressure information. Cursor types may also describe different optional hardware configurations. The interface defines a standard orientation for reporting device native coordinates. When the user is viewing the device in its normal position, the coordinate origin will be at the lower left of the device. The coordinate system will be right-handed, that is, the positive x axis points from left to right, and the posi¬tive y axis points either upward or away from the user. The z axis, if supported, points either to¬ward the user or upward. For devices that lay flat on a table top, the x-y plane will be horizontal and the z axis will point upward. For devices that are oriented vertically (for example, a touch screen on a conventional dis¬play), the x-y plane will be vertical, and the z axis will point toward the user. 3.2 Device Information Any program can get descriptive information about the tablet via the WTInfo function. The interface specifies certain information that must be available, but allows new implementations to add new types of information. The basic information includes device identifiers, version numbers, and overall ca¬pabilities. The information items are organized by category and index numbers. The combination of a category and index specifies a single information data item, which may be a scalar value, string, structure, or array. Applica¬tions may retrieve single items or whole categories at once. Some categories are multiplexed. A single category code represents the first of a group of identically in-dexed categories, one for each of a set of similar objects. Multiplexed categories in¬clude those for devices and cur¬sor types. One constructs the category number by adding the defined cate¬gory code to a zero-based device or cursor identification number. The information is read-only for normal tablet applications. Some information items may change during the course of a Windows session; tablet applications receive messages notifying them of changes in tablet information. 3.3 Tablet Contexts Tablet contexts play a central role in the interface; they are the objects that applications use to specify their use of the tablet. Con¬texts include not only the physical area of the tablet that the application will use, but also information about the type, con¬tents, and delivery method for tablet events, as well as other information. Tablet contexts are somewhat analo¬gous to display contexts in the GDI interface model; they contain context information about a spe¬cific application's use of the tablet. An application can open more than one context, but most only need one. Applications can customize their contexts, or they can open a context using a default context specification that is always available. The WTInfo function provides access to the default context specification. Opening a context requires a window handle. The window handle becomes the context's owner and will receive any window messages associated with the context. Contexts are remotely similar to screen windows in that they can physically overlap. The tablet inter¬face uses a combination of context overlap order and context attributes to decide which context will process a given event. The topmost context in the overlap order whose input context encompasses the event, and whose event masks select the event, will process the event. (Note that the notion of overlap order is sepa-rate from the notion of the physical z dimension.) Tablet managers (described below) provide a way to modify and overlap contexts. 3.4 Event Packets Tablet contexts generate and report tablet activity via event packets. Applications can control how they receive events, which events they receive, and what information they contain. Applications may receive events either by polling, or via Windows messages. • Polling: Any application that has opened a context can call the WTPacketsGet function to get the next state of the tablet for that context. • Window Messages: Applications that request messages will receive the WT_PACKET mes¬sage (described below), which indicates that something happened in the context and provides a refer-ence to more information. Applications can control which events they receive by using event masks. For example, some appli¬ca¬tions may only need to know when a button is pressed, while others may need to receive an event every time the cursor moves. Tablet context event masks implement this type of control. Applications can control the contents of the event packets they receive. Some tablets can return data that many applications will not need, like button pressure and three dimensional position and orien¬tation in-formation. The context object provides a way of specifying which data items the appli¬cation needs. This allows the driver to improve the efficiency of packet delivery to applications that only need a few items per packet. Packets are stored in context-specific packet queues and retrieved by explicit function calls. The interface provides ways to peek at and get packets, to query the size and contents of the queue, and to re-size the queue. 3.5 Tablet Managers The interface provides functions for tablet management. An application can become a tablet manager by opening a tablet manager handle. This handle allows the manager access to spe¬cial functions. These man-agement functions allow the application to arrange, overlap, and modify tablet contexts. Man¬agers may also perform other functions, such as changing default values used by applica¬tions, chang¬ing ergo¬nomic, preference, and configuration settings, controlling tablet behavior with non-tablet aware applica¬tions, modi¬fy¬ing user dialogs, and recording and playing back tablet packets. Opening a manager handle re¬quires a window handle. The window becomes a manager window and receives window messages about interface and con¬text activity. 3.6 Extensions The interface allows implementations to define additional features called extensions. Extensions can be made available to new applications without the need to modify ex¬isting applications. Extensions are sup-ported through the information categories, through the flexible definition of packets, and through special context and manager functions. Designing an extension involves defining the meaning and behavior of the extension packet and/or prefer-ence data, filling in the information category, defining the extension's interface with the special functions, and possibly defining additional functions to support the extension. Each extension will be assigned a unique tag for identification. Not all implementations will support all extensions. A multiplexed information category contains descriptive data about extensions. Note that applica¬tions must find their extensions by iterating through the categories and matching tags. While tags are fixed across all implementations, category numbers may vary among implementations. 3.7 Persistent Binding of Interface Features (1.1) The interface provides access to many of its features using consecutive numeric indices whose value is not guaranteed from session to session. However, sufficient information is provided to create unique identifi¬ers for devices, cursors, and interface extensions. Devices should be uniquely identified by the contents of their name strings. If multiple identical devices are present, implementation providers should provide unique, persistent id strings to the extent possible. Identical devices that return unique serial numbers are ideal. If supported by the hardware, cursors also may have a physical cursor id that uniquely identifies the cursor in a persistent and stable manner. Interface extensions are uniquely identified by their tag. 4 INTERFACE IMPLEMENTATIONS Implementations of this interface usually support one specific device, a class of similar devices, or a com-mon combination of devices. The following sections discuss guidelines for implementations. 4.1 File and Module Conventions For 16-bit implementations, the interface functions, and any additional vendor- or device-specific func-tions, reside in a dynamic link library with the file name "WINTAB.DLL" and module name "WINTAB"; 32-bit implementations use the file name "WINTAB32.DLL" and module name "WINTAB32." Any other file or module con¬ventions are implementation specific. Implementations may include other library mod-ules or data files as necessary. Installation processes are likewise implementa¬tion-specific. Wintab programs written in the C language require two header files. WINTAB.H contains definitions of all of the functions, constants, and fixed data types. PKTDEF.H contains a parameterized definition of the PACKET data structure, that can be tailored to fit the application. The Wintab Programmer's Kit con¬tains these and other files necessary for Wintab programming, plus several example programs with C-lan¬guage source files. The Wintab Programmer's Kit is available from the author. 4.2 Feature Support Options Some features of the interface are optional and may be left out by some implementations. Support of defined data items other than x, y, and buttons is optional. Many devices only report x, y, and button information. Support of system-cursor contexts is optional. This option relieves implementations of replacing the sys¬tem mouse driver in Windows versions before 3.1. Support of Pen Windows contexts is optional. Not all systems will have the Pen Windows hardware and software necessary. Support of external tablet manager applications is optional, and the number of manager handles is imple-mentation-dependent. However, the manager functions should be present in all implementa¬tions, return¬ing appropriate failure codes if not fully implemented. An implementation may provide context- and hardware-management support internally only, if desired. On the other hand, providing the external man-ager interface may relieve the implementation of a considerable amount of user in¬terface code, and make improvements to the manager interface easier to implement and distribute later. Support of extension data items is optional. Most extensions will be geared to unusual hardware features. 5 FUNCTION REFERENCE All tablet function names have the prefix "WT" and have attributes equivalent to WINAPI. Applica¬tions gain access to the tablet interface functions through a dynamic-link library with standard file and module names, as defined in the previous section. Applications may link to the functions by using the Windows functions LoadLibrary, FreeLibrary, and GetProcAddress, or use an import library. Specific to 32-bit Wintab: The functions WTInfo, WTOpen, WTGet, and WTSet have both ANSI and Unicode versions, using the same ANSI/Unicode porting conventions used in the Win32 API. Five non-portable functions, WTQueuePackets, WTMgrCsrPressureBtnMarks, WTMgrConfigReplace, WTMgrPacketHook, and WTMgrPacketHookDefProc are replaced by new portable functions WTQueuePacketsEx, WTMgrCsrPressureBtnMarksEx, WTMgrConfigReplaceEx, WTMgrPack-etHookEx, WTMgrPacketUnhook, and WTMgrPacketHookNext. WTMgrConfigReplaceEx and WTMgrPacketHookEx have both ANSI and Unicode versions. Table 5.1. Ordinal Function Numbers for Dynamic Linking Ordinal numbers for dynamic linking are defined in the table below. Where two ordinal entries appear, the first entry identifies the 16-bit and 32-bit ANSI versions of the function. The second entry identifies the 32-bit Unicode version. Function Name Ordinal Function Name Ordinal WTInfo 20, 1020 WTMgrOpen 100 WTOpen 21, 1021 WTMgrClose 101 WTClose 22 WTMgrContextEnum 120 WTPacketsGet 23 WTMgrContextOwner 121 WTPacket 24 WTMgrDefContext 122 WTEnable 40 WTMgrDefContextEx (1.1) 206 WTOverlap 41 WTMgrDeviceConfig 140 WTConfig 60 WTMgrConfigReplace 141 WTGet 61, 1061 WTMgrConfigReplaceEx 202, 1202 WTSet 62, 1062 WTMgrPacketHook 160 WTExtGet 63 WTMgrPacketHookEx 203, 1203 WTExtSet 64 WTMgrPacketUnhook 204 WTSave 65 WTMgrPacketHookDefProc 161 WTRestore 66 WTMgrPacketHookNext 205 WTPacketsPeek 80 WTMgrExt 180 WTDataGet 81 WTMgrCsrEnable 181 WTDataPeek 82 WTMgrCsrButtonMap 182 WTQueuePackets 83 WTMgrCsrPressureBtnMarks 183 WTQueuePacketsEx 200 WTMgrCsrPressureBtnMarksEx 201 WTQueueSizeGet 84 WTMgrCsrPressureResponse 184 WTQueueSizeSet 85 WTMgrCsrExt 185 5.1 Basic Functions The functions in the following section will be used by most tablet-aware applications. They include getting interface and device information, opening and closing contexts, and retrieving packets by polling or via Windows messages. 5.1.1 WTInfo Syntax UINT WTInfo(wCategory, nIndex, lpOutput) This function returns global information about the interface in an application-sup-plied buffer. Different types of information are specified by different index argu-ments. Applications use this function to receive information about tablet coordi-nates, physical dimensions, capabilities, and cursor types. Parameter Type/Description wCategory UINT Identifies the category from which information is being re-quested. nIndex UINT Identifies which information is being requested from within the category. lpOutput LPVOID Points to a buffer to hold the requested information. Return Value The return value specifies the size of the returned information in bytes. If the infor-mation is not supported, the function returns zero. If a tablet is not physi¬cally pres-ent, this function always returns zero. Comments Several important categories of information are available through this function. First, the function provides identification information, including specification and software version numbers, and tablet vendor and model information. Sec¬ond, the function provides general capability information, including dimensions, resolutions, optional features, and cursor types. Third, the function provides categories that give defaults for all tablet context attributes. Finally, the func¬tion may provide any other implementation- or vendor-specific information cat¬egories necessary. The information returned by this function is subject to change during a Win¬dows session. Applications cannot change the information returned here, but tablet man-ager applications or hardware changes or errors can. Applications can respond to information changes by fielding the WT_INFOCHANGE message. The parameters of the message indicate which information has changed. If the wCategory argument is zero, the function copies no data to the output buffer, but returns the size in bytes of the buffer necessary to hold the largest complete category. If the nIndex argument is zero, the function returns all of the information entries in the category in a single data structure. If the lpOutput argument is NULL, the function just returns the required buffer size. See Also Category and index definitions in tables 7.3 through 7.9, and the WT_INFOCHANGE message in section 6.3.1. 5.1.2 WTOpen Syntax HCTX WTOpen(hWnd, lpLogCtx, fEnable) This function establishes an active context on the tablet. On successful comple¬tion of this function, the application may begin receiving tablet events via mes¬sages (if they were requested), and may use the handle returned to poll the con¬text, or to per-form other context-related functions. Parameter Type/Description hWnd HWND Identifies the window that owns the tablet context, and receives messages from the context. lpLogCtx LPLOGCONTEXT Points to an application-provided LOGCONTEXT data structure describing the context to be opened. fEnable BOOL Specifies whether the new context will immediately begin processing input data. Return Value The return value identifies the new context. It is NULL if the context is not opened. Comments Opening a new context allows the application to receive tablet input or creates a context that controls the system cursor or Pen Windows pen. The owning window (and all manager windows) will immediately receive a WT_CTXOPEN message when the context has been opened. If the fEnable argument is zero, the context will be created, but will not process input. The context can be enabled using the WTEnable function. If tablet event messages were requested in the context specification, the owning window will receive them. The application can control the message numbers used the lcMsgBase field of the LOGCONTEXT structure. The window that owns the new context will receive context and information change messages even if event messages were not requested. It is not necessary to handle these in many cases, but some applications may wish to do so. The newly opened tablet context will be placed on the top of the context overlap or-der. Invalid or out-of-range attribute values in the logical context structure will ei¬ther be validated, or cause the open to fail, depending on the attributes involved. Upon a successful return from the function, the context specification pointed to by lpLogCtx will contain the validated values. See Also The WTEnable function in section 5.2.1, the LOGCONTEXT data structure in section 7.3.1, and the context and infor¬mation change messages in sections 6.2 and 6.3. 5.1.3 WTClose Syntax BOOL WTClose(hCtx) This function closes and destroys the tablet context object. Parameter Type/Description hCtx HCTX Identifies the context to be closed. Return Value The function returns a non-zero value if the context was valid and was destroyed. Otherwise, it returns zero. Comments After a call to this function, the passed handle is no longer valid. The owning win¬dow (and all manager windows) will receive a WT_CTXCLOSE message when the context has been closed. See Also The WTOpen function in section 5.1.2. 5.1.4 WTPacketsGet Syntax int WTPacketsGet(hCtx, cMaxPkts, lpPkts) This function copies the next cMaxPkts events from the packet queue of context hCtx to the passed lpPkts buffer and removes them from the queue. Parameter Type/Description hCtx HCTX Identifies the context whose packets are being returned. cMaxPkts int Specifies the maximum number of packets to return. lpPkts LPVOID Points to a buffer to receive the event packets. Return Value The return value is the number of packets copied in the buffer. Comments The exact structure of the returned packet is determined by the packet infor¬mation that was requested when the context was opened. The buffer pointed to by lpPkts must be at least cMaxPkts * sizeof(PACKET) bytes long to prevent overflow. Applications may flush packets from the queue by calling this function with a NULL lpPkt argument. See Also The WTPacketsPeek function in section 5.4.1, and the descriptions of the LOGCONTEXT (section 7.3.1) and PACKET (section 7.4.1) data structures. 5.1.5 WTPacket Syntax BOOL WTPacket(hCtx, wSerial, lpPkt) This function fills in the passed lpPkt buffer with the context event packet having the specified serial number. The returned packet and any older packets are removed from the context's internal queue. Parameter Type/Description hCtx HCTX Identifies the context whose packets are being returned. wSerial UINT Serial number of the tablet event to return. lpPkt LPVOID Points to a buffer to receive the event packet. Return Value The return value is non-zero if the specified packet was found and returned. It is zero if the specified packet was not found in the queue. Comments The exact structure of the returned packet is determined by the packet infor¬mation that was requested when the context was opened. The buffer pointed to by lpPkts must be at least sizeof(PACKET) bytes long to pre-vent overflow. Applications may flush packets from the queue by calling this function with a NULL lpPkts argument. See Also The descriptions of the LOGCONTEXT (section 7.3.1) and PACKET (section 7.4.1) data structures. 5.2 Visibility Functions The functions in this section allow applications to control contexts' visibility, whether or not they are pro-cessing input, and their overlap order. 5.2.1 WTEnable Syntax BOOL WTEnable(hCtx, fEnable) This function enables or disables a tablet context, temporarily turning on or off the processing of packets. Parameter Type/Description hCtx HCTX Identifies the context to be enabled or disabled. fEnable BOOL Specifies enabling if non-zero, disabling if zero. Return Value The function returns a non-zero value if the enable or disable request was satis¬fied, zero otherwise. Comments Calls to this function to enable an already enabled context, or to disable an al¬ready disabled context will return a non-zero value, but otherwise do nothing. The context’s packet queue is flushed on disable. Applications can determine whether a context is currently enabled by using the WTGet function and examining the lcStatus field of the LOGCONTEXT struc¬ture. See Also The WTGet function in section 5.3.2, and the LOGCONTEXT structure in sec¬tion 7.3.1. 5.2.2 WTOverlap Syntax BOOL WTOverlap(hCtx, fToTop) This function sends a tablet context to the top or bottom of the order of over¬lapping tablet contexts. Parameter Type/Description hCtx HCTX Identifies the context to move within the overlap order. fToTop BOOL Specifies sending the context to the top of the overlap or-der if non-zero, or to the bottom if zero. Return Value The function returns non-zero if successful, zero otherwise. Comments Tablet contexts' input areas are allowed to overlap. The tablet interface main¬tains an overlap order that helps determine which context will process a given event. The topmost context in the overlap order whose input context encom¬passes the event, and whose event masks select the event will process the event. This function is useful for getting access to input events when the application's con-text is overlapped by other contexts. The function will fail only if the context argument is invalid. 5.3 Context Editing Functions This group of functions allows applications to edit, save, and restore contexts. 5.3.1 WTConfig Syntax BOOL WTConfig(hCtx, hWnd) This function prompts the user for changes to the passed context via a dialog box. Parameter Type/Description hCtx HCTX Identifies the context that the user will modify via the dialog box. hWnd HWND Identifies the window that will be the parent window of the dialog box. Return Value The function returns a non-zero value if the tablet context was changed, zero oth-erwise. Comments Tablet applications can use this function to let the user choose context attributes that the application doesn't need to control. Applications can control the editing of con¬text attributes via the lcLocks logical context structure member. Applications should consider providing access to this function through a menu item or command. See Also The LOGCONTEXT structure in section 7.3.1 and the context lock values in table 7.13. 5.3.2 WTGet Syntax BOOL WTGet(hCtx, lpLogCtx) This function fills the passed structure with the current context attributes for the passed handle. Parameter Type/Description hCtx HCTX Identifies the context whose attributes are to be copied. lpLogCtx LPLOGCONTEXT Points to a LOGCONTEXT data structure to which the context attributes are to be copied. Return Value The function returns a non-zero value if the data is retrieved successfully. Oth¬er¬wise, it returns zero. See Also The LOGCONTEXT structure in section 7.3.1. 5.3.3 WTSet (1.1 modified) Syntax BOOL WTSet(hCtx, lpLogCtx) This function allows some of the context's attributes to be changed on the fly. Parameter Type/Description hCtx HCTX Identifies the context whose attributes are being changed. lpLogCtx LPLOGCONTEXT Points to a LOGCONTEXT data structure containing the new context attributes. Return Value The function returns a non-zero value if the context was changed to match the passed context specification; it returns zero if any of the requested changes could not be made. Comments If this function is called by the task or process that owns the context, any context attribute may be changed. Otherwise, the function can change attributes that do not affect the format or meaning of the context's event packets and that were not speci-fied as locked when the context was opened. Context lock values can only be changed by the context’s owner. 1.1: If the hCtx argument is a default context handle returned from WTMgrDef-Context or WTMgrDefContextEx, and the lpLogCtx argument is WTP_LPDEFAULT, the default context will be reset to its initial factory default values. See Also The LOGCONTEXT structure in section 7.3.1 and the context lock values in table 7.13. 5.3.4 WTExtGet Syntax BOOL WTExtGet(hCtx, wExt, lpData) This function retrieves any context-specific data for an extension. Parameter Type/Description hCtx HCTX Identifies the context whose extension attributes are being retrieved. wExt UINT Identifies the extension tag for which context-specific data is being retrieved. lpData LPVOID Points to a buffer to hold the retrieved data. Return Value The function returns a non-zero value if the data is retrieved successfully. Oth¬er¬wise, it returns zero. See Also The extension definitions in Appendix B. 5.3.5 WTExtSet Syntax BOOL WTExtSet(hCtx, wExt, lpData) This function sets any context-specific data for an extension. Parameter Type/Description hCtx HCTX Identifies the context whose extension attributes are being modified. wExt UINT Identifies the extension tag for which context-specific data is being modified. lpData LPVOID Points to the new data. Return Value The function returns a non-zero value if the data is modified successfully. Oth¬er¬wise, it returns zero. Comments Extensions may forbid their context-specific data to be changed during the life¬time of a context. For such extensions, calls to this function would always fail. Extensions may also limit context data editing to the task of the owning window, as with the context locks. See Also The extension definitions in Appendix B, the LOGCONTEXT data structure in section 7.3.1 and the context locking values in table 7.13. 5.3.6 WTSave Syntax BOOL WTSave(hCtx, lpSaveInfo) This function fills the passed buffer with binary save information that can be used to restore the equivalent context in a subsequent Windows session. Parameter Type/Description hCtx HCTX Identifies the context that is being saved. lpSaveInfo LPVOID Points to a buffer to contain the save information. Return Value The function returns non-zero if the save information is successfully retrieved. Oth-erwise, it returns zero. Comments The size of the save information buffer can be determined by calling the WTInfo function with category WTI_INTERFACE, index IFC_CTXSAVESIZE. The save information is returned in a private binary data format. Applications should store the information unmodified and recreate the context by passing the save information to the WTRestore function. Using WTSave and WTRestore allows applications to easily save and restore ex-tension data bound to contexts. See Also The WTRestore function in section 5.3.7. 5.3.7 WTRestore Syntax HCTX WTRestore(hWnd, lpSaveInfo, fEnable) This function creates a tablet context from save information returned from the WTSave function. Parameter Type/Description hWnd HWND Identifies the window that owns the tablet context, and receives messages from the context. lpSaveInfo LPVOID Points to a buffer containing save information. fEnable BOOL Specifies whether the new context will immediately begin processing input data. Return Value The function returns a valid context handle if successful. If a context equivalent to the save information could not be created, the function returns NULL. Comments The save information is in a private binary data format. Applications should only pass save information retrieved by the WTSave function. This function is much like WTOpen, except that it uses save in¬formation for input instead of a logical context. In particular, it will generate a WT_CTXOPEN mes¬sage for the new context. See Also The WTOpen function in section 5.1.2, the WTSave function in section 5.3.6, and the WT_CTXOPEN message in section 6.2.1. 5.4 Advanced Packet and Queue Functions These functions provide advanced packet retrieval and queue manipulation. The packet retrieval functions require the application to provide a packet output buffer. To prevent overflow, the buffer must be large enough to hold the requested number of packets from the specified context. It is up to the caller to deter¬mine the packet size (by interrogating the context, if necessary), and to allocate a large enough buffer. Ap¬plications may flush packets from the queue by passing a NULL buffer pointer. 5.4.1 WTPacketsPeek Syntax int WTPacketsPeek(hCtx, cMaxPkts, lpPkts) This function copies the next cMaxPkts events from the packet queue of context hCtx to the passed lpPkts buffer without removing them from the queue. Parameter Type/Description hCtx HCTX Identifies the context whose packets are being read. cMaxPkts int Specifies the maximum number of packets to return. lpPkts LPVOID Points to a buffer to receive the event packets. Return Value The return value is the number of packets copied in the buffer. Comments The buffer pointed to by lpPkts must be at least cMaxPkts * sizeof(PACKET) bytes long to prevent overflow. See Also the WTPacketsGet function in section 5.1.4. 5.4.2 WTDataGet Syntax int WTDataGet(hCtx, wBegin, wEnd, cMaxPkts, lpPkts, lpNPkts) This function copies all packets with serial numbers between wBegin and wEnd in-clusive from the context's queue to the passed buffer and removes them from the queue. Parameter Type/Description hCtx HCTX Identifies the context whose packets are being returned. wBegin UINT Serial number of the oldest tablet event to return. wEnd UINT Serial number of the newest tablet event to return. cMaxPkts int Specifies the maximum number of packets to return. lpPkts LPVOID Points to a buffer to receive the event packets. lpNPkts LPINT Points to an integer to receive the number of packets ac-tually copied. Return Value The return value is the total number of packets found in the queue between wBegin and wEnd. Comments The buffer pointed to by lpPkts must be at least cMaxPkts * sizeof(PACKET) bytes long to prevent overflow. See Also The WTDataPeek function in section 5.4.3, and the WTQueuePacketsEx function in section 5.4.5. 5.4.3 WTDataPeek Syntax int WTDataPeek(hCtx, wBegin, wEnd, cMaxPkts, lpPkts, lpNPkts) This function copies all packets with serial numbers between wBegin and wEnd in-clusive, from the context's queue to the passed buffer without removing them from the queue. Parameter Type/Description hCtx HCTX Identifies the context whose packets are being read. wBegin UINT Serial number of the oldest tablet event to return. wEnd UINT Serial number of the newest tablet event to return. cMaxPkts int Specifies the maximum number of packets to return. lpPkts LPVOID Points to a buffer to receive the event packets. lpNPkts LPINT Points to an integer to receive the number of packets ac-tually copied. Return Value The return value is the total number of packets found in the queue between wBegin and wEnd. Comments The buffer pointed to by lpPkts must be at least cMaxPkts * sizeof(PACKET) bytes long to prevent overflow. See Also The WTDataGet function in section 5.4.2, and the WTQueuePacketsEx function in section 5.4.5. 5.4.4 WTQueuePackets (16-bit only) Syntax DWORD WTQueuePackets(hCtx) This function returns the serial numbers of the oldest and newest packets cur¬rently in the queue. Parameter Type/Description hCtx HCTX Identifies the context whose queue is being queried. Return Value The high word of the return value contains the newest packet's serial number; the low word contains the oldest. Comments This function is non-portable and is superseded by WTQueuePacketsEx. See Also The WTQueuePacketsEx function in section 5.4.5. 5.4.5 WTQueuePacketsEx Syntax BOOL WTQueuePacketsEx(hCtx, lpOld, lpNew) This function returns the serial numbers of the oldest and newest packets cur¬rently in the queue. Parameter Type/Description hCtx HCTX Identifies the context whose queue is being queried. lpOld UINT FAR * Points to an unsigned integer to receive the oldest packet's serial number. lpNew UINT FAR * Points to an unsigned integer to receive the newest packet's serial number. Return Value The function returns non-zero if successful, zero otherwise. 5.4.6 WTQueueSizeGet Syntax int WTQueueSizeGet(hCtx) This function returns the number of packets the context's queue can hold. Parameter Type/Description hCtx HCTX Identifies the context whose queue size is being re¬turned. Return Value The return value is the number of packet the queue can hold. See Also The WTQueueSizeSet function in section 5.4.7. 5.4.7 WTQueueSizeSet Syntax BOOL WTQueueSizeSet(hCtx, nPkts) This function attempts to change the context's queue size to the value specified in nPkts. Parameter Type/Description hCtx HCTX Identifies the context whose queue size is being set. nPkts int Specifies the requested queue size. Return Value The return value is non-zero if the queue size was successfully changed. Other¬wise, it is zero. Comments If the return value is zero, the context has no queue because the function deletes the original queue before attempting to create a new one. The application must continue calling the function with a smaller queue size until the function returns a non-zero value. See Also The WTQueueSizeGet function in section 5.4.6. 5.5 Manager Handle Functions The functions described in this and subsequent sections are for use by tablet manager applications. The functions of this section create and destroy manager handles. These handles allow the interface code to limit the degree of simultaneous access to the powerful manager functions. Also, opening a manager handle lets the application receive messages about tablet interface activity. 5.5.1 WTMgrOpen Syntax HMGR WTMgrOpen(hWnd, wMsgBase) This function opens a tablet manager handle for use by tablet manager and con¬figu-ration applications. This handle is required to call the tablet management func¬tions. Parameter Type/Description hWnd HWND Identifies the window which owns the manager handle. wMsgBase UINT Specifies the message base number to use when notifying the manager window. Return Value The function returns a manager handle if successful, otherwise it returns NULL. Comments While the manager handle is open, the manager window will receive context mes-sages from all tablet contexts. Manager windows also receive information change messages. The number of manager handles available is interface implementation-dependent, and can be determined by calling the WTInfo function with category WTI_INTERFACE and index IFC_NMANAGERS. See Also The WTInfo function in section 5.1.1, the WTMgrClose function in section 5.5.2, the description of message base numbers in section 6 and the context and in¬for¬ma-tion change messages in sections 6.2 and 6.3. 5.5.2 WTMgrClose Syntax BOOL WTMgrClose(hMgr) This function closes a tablet manager handle. After this function returns, the passed manager handle is no longer valid. Parameter Type/Description hMgr HMGR Identifies the manager handle to close. Return Value The function returns non-zero if the handle was valid; otherwise, it returns zero. 5.6 Manager Context Functions These functions provide access to all open contexts and their owners, and allow changing context de¬faults. Only tablet managers are allowed to manipulate tablet contexts belonging to other applica¬tions. 5.6.1 WTMgrContextEnum Syntax BOOL WTMgrContextEnum(hMgr, lpEnumFunc, lParam) This function enumerates all tablet context handles by passing the handle of each context, in turn, to the callback function pointed to by the lpEnumFunc pa¬rameter. The enumeration terminates when the callback function returns zero. Parameter Type/Description hMgr HMGR Is the valid manager handle that identifies the caller as a manager application. lpEnumFunc WTENUMPROC Is the procedure-instance address of the call-back function. See the following "Comments" section for details. lParam LPARAM Specifies the value to be passed to the callback func-tion for the application's use. Return Value The return value specifies the outcome of the function. It is non-zero if all con¬texts have been enumerated. Otherwise, it is zero. Comments The address passed as the lpEnumFunc parameter must be created by using the MakeProcInstance function. The callback function must have attributes equivalent to WINAPI. The callback function must have the following form: Callback BOOL WINAPI EnumFunc(hCtx, lParam) HCTX hCtx; LPARAM lParam; EnumFunc is a place holder for the application-supplied function name. The actual name must be exported by including it in an EXPORTS statement in the applica-tion's module-definition file. Parameter Description hCtx Identifies the context. lParam Specifies the 32-bit argument of the WTMgrContextEnum func-tion. Return Value The function must return a non-zero value to continue enumeration, or zero to stop it. 5.6.2 WTMgrContextOwner Syntax HWND WTMgrContextOwner(hMgr, hCtx) This function returns the handle of the window that owns a tablet context. Parameter Type/Description hMgr HMGR Is the valid manager handle that identifies the caller as a manager application. hCtx HCTX Identifies the context whose owner is to be returned. Return Value The function returns the context owner's window handle if the passed arguments are valid. Otherwise, it returns NULL. Comments This function allows the tablet manager to coordinate tablet context manage¬ment with the states of the context-owning windows. 5.6.3 WTMgrDefContext Syntax HCTX WTMgrDefContext(hMgr, fSystem) This function retrieves a context handle that allows setting values for the current default digit¬izing or system context. Parameter Type/Description hMgr HMGR Is the valid manager handle that identifies the caller as a manager application. fSystem BOOL Specifies retrieval of the default system context if non-zero, or the default digitizing context if zero. Return Value The return value is the context handle for the specified default context, or NULL if the arguments were invalid. Comments The default digitizing context is the context whose attributes are returned by the WTInfo function WTI_DEFCONTEXT category. The default system context is the context whose attributes are returned by the WTInfo function WTI_DEFSYSCTX category. Editing operations on the retrieved handles will fail if the new default contexts do not meet certain requirements. The digitizing context must include at least buttons, x, and y in its packet data, and must return absolute coordinates. 1.1: Editing the current default digitizing context will also update the device-spe¬cific default context for the device listed in the lcDevice field of the default con¬text’s LOGCONTEXT structure. See Also The WTInfo function in section 5.1.1 the WTMgrDefContextEx function in section 5.6.4, and the category and index definitions in tables 7.3 through 7.9. 5.6.4 WTMgrDefContextEx (1.1) Syntax HCTX WTMgrDefContextEx(hMgr, wDevice, fSystem) This function retrieves a context handle that allows setting values for the default digit¬izing or system context for a specified device. Parameter Type/Description hMgr HMGR Is the valid manager handle that identifies the caller as a manager application. wDevice UINT Specifies the device for which a default context handle will be returned. fSystem BOOL Specifies retrieval of the default system context if non-zero, or the default digitizing context if zero. Return Value The return value is the context handle for the specified default context, or NULL if the arguments were invalid. Comments The default digitizing contexts are contexts whose attributes are returned by the WTInfo function WTI_DDCTXS multiplexed category. The default system con-texts are contexts whose attributes are returned by the WTInfo function WTI_DSCTXS multiplexed category. Editing operations on the retrieved handles will fail if the new default contexts do not meet certain requirements. The digitizing context must include at least buttons, x, and y in its packet data, and must return absolute coordinates. See Also The WTInfo function in section 5.1.1, and the category and index definitions in tables 7.3 through 7.9. 5.7 Manager Configuration Functions These functions allow manager applications to replace the default context configuration dialog and to display a configuration dialog for each hardware device. 5.7.1 WTMgrDeviceConfig Syntax UINT WTMgrDeviceConfig(hMgr, wDevice, hWnd) This function displays a custom modal tablet-hardware configuration dialog box, if one is supported. Parameter Type/Description hMgr HMGR Is the valid manager handle that identifies the caller as a manager application. wDevice UINT Identifies the device that the user will configure via the dialog box. hWnd HWND Identifies the window that will be the parent window of the dialog box. If this argument is NULL, the function will return non-zero if the dialog is supported, or zero otherwise. Return Value The return value is zero if the dialog box is not supported. Otherwise, it is one of the following non-zero values. Value Meaning WTDC_CANCEL The user canceled the dialog without making any changes. WTDC_OK The user made and confirmed changes. WTDC_RESTART The user made and confirmed changes that require a sys-tem restart in order to take effect. The calling program should query the user to determine whether to restart. Restart Windows using the function call ExitWin-dows(EW_RESTARTWINDOWS, 0);. 5.7.2 WTMgrConfigReplace (16-bit only) Syntax BOOL WTMgrConfigReplace(hMgr, fInstall, lpConfigProc) This function allows a manager application to replace the default behavior of the WTConfig function. Parameter Type/Description hMgr HMGR Is the valid manager handle that identifies the caller as a manager application. fInstall BOOL Specifies installation of a replacement function if non-zero, or removal of the current replacement if zero. lpConfigProc WTCONFIGPROC Is the procedure-instance address of the new configuration function. This argument is ignored during a re¬moval request. Return Value The function return non-zero if the installation or removal request succeeded. Oth-erwise, it returns zero. Comments This function is non-portable and is superseded by WTMgrConfigReplaceEx. See Also The WTConfig function in section 5.3.1, and for a description of the configuration callback function, see the WTMgrConfigReplaceEx function in section 5.7.3. 5.7.3 WTMgrConfigReplaceEx Syntax BOOL WTMgrConfigReplaceEx(hMgr, fInstall, lpszModule, lpszCfgProc) This function allows a manager application to replace the default behavior of the WTConfig function. Parameter Type/Description hMgr HMGR Is the valid manager handle that identifies the caller as a manager application. fInstall BOOL Specifies installation of a replacement function if non-zero, or removal of the current replacement if zero. lpszModule LPCTSTR Points to a null-terminated string that names a DLL module containing the new configuration function. This argument is ignored during a re¬moval request lpszCfgProc LPCSTR Points to a null-terminated string that names the new configuration function. This argument is ignored during a re¬moval request. Return Value The function return non-zero if the installation or removal request succeeded. Oth-erwise, it returns zero. Comments The configuration callback function must have attributes equivalent to WINAPI. Only one callback function may be installed at a time. The manager handle passed with the removal request must match the handle passed with the corre¬sponding in-stallation request. Tablet managers that install a replacement context configuration function must re-move it before exiting. Callback BOOL WINAPI ConfigProc(hWnd, hCtx) HWND hWnd; HCTX hCtx; ConfigProc is a place holder for the application-supplied function name. The actual name must be exported by including it in an EXPORTS statement in the applica-tion's module-definition file. Parameter Description hWnd Identifies the window that will be the parent window of the dialog box. hCtx Identifies the context that the user will modify via the dialog box. Return Value The function returns a non-zero value if the tablet context was changed, zero oth-erwise. Comments The configuration function and resulting dialog box should analyze the lcLocks context structure member, and only allow editing of unlocked context attributes. See Also The WTConfig function in section 5.3.1. 5.8 Manager Packet Hook Functions These functions allow manager applications to monitor, record, and play back sequences of tablet packets. 5.8.1 WTMgrPacketHook (16-bit only) Syntax WTHOOKPROC WTMgrPacketHook(hMgr, fInstall, nType, lpFunc) This function installs or removes a packet hook function. Parameter Type/Description hMgr HMGR Is the valid manager handle that identifies the caller as a manager application. fInstall BOOL Specifies installation of a hook function if non-zero, or removal of the specified hook if zero. nType int Specifies the packet hook to be installed. It can be any one of the following values: Value Meaning WTH_PLAYBACK Installs a packet playback hook. WTH_RECORD Installs a packet record hook. lpFunc WTHOOKPROC Is the procedure-instance address of the hook function to be installed. See the "Comments" section under WTMgrPacketHookEx for details. Return Value When installing a hook, the return value points to the procedure-instance ad¬dress of the previously installed hook (if any). It is NULL if there is no previous hook; it is negative one if the hook cannot be installed. The application or library that calls this func¬tion should save this return value in the library's data segment. The fourth argument of the WTPacketHookDefProc function points to the location in memory where the library saves this return value. When removing a hook, the return value is the passed lpFunc if successful, NULL otherwise. Comments This function is non-portable and is superseded by WTMgrPacketHookEx and WTMgrPacketUnhook. See Also the WTMgrPacketHookEx function in section 5.8.2, and the WTMgrPacketUn-hook function in section 5.8.3. 5.8.2 WTMgrPacketHookEx Syntax HWTHOOK WTMgrPacketHookEx(hMgr, nType, lpszModule, lpszHookProc) This function installs a packet hook function. Parameter Type/Description hMgr HMGR Is the valid manager handle that identifies the caller as a manager application. nType int Specifies the packet hook to be installed. It can be any one of the following values: Value Meaning WTH_PLAYBACK Installs a packet playback hook. WTH_RECORD Installs a packet record hook. lpszModule LPCTSTR Points to a null-terminated string that names a DLL module containing the new hook function. See the following "Comments" section for details. lpszHookProc LPCSTR Points to a null-terminated string that names the new hook function. See the following "Comments" section for details. Return Value If the function succeeds, the return value is the handle of the installed hook func-tion. Otherwise, the return value is NULL. Comments Packet hooks are a shared resource. Installing a hook affects all applications using the interface. All Wintab hook functions must be exported functions residing in a DLL module. The following section describes how to support the individual hook functions. WTH_PLAYBACK Wintab calls the WTH_PLAYBACK hook whenever a request for an event packet is made. The function is intended to be used to supply a previously recorded event packet for a compatible context. The hook function must have attributes equivalent to WINAPI. The filter function must have the following form: Hook Function LRESULT WINAPI HookFunc(nCode, wParam, lParam); int nCode; WPARAM wParam; LPARAM lParam; HookFunc is a place holder for the library-supplied function name. The actual name must be exported by including it in an EXPORTS statement in the library's mod¬ule-definition file. Parameter Description nCode Specifies whether the hook function should process the mes¬sage or call the WTMgrPacketHookDefProc (if installed by WTMgrPacketHook)or WTMgrPacketHookNext (if installed by WTMgrPacketHookEx) function. If the nCode parame¬ter is less than zero, the hook function should pass the message to the appropriate function without further process¬ing. wParam Specifies the context handle whose event is being requested. lParam Points to the packet being processed by the hook function. Comments The WTH_PLAYBACK function should copy an event packet to the buffer pointed to by the lParam pa¬rameter. The packet must have been previously recorded by us-ing the WTH_RECORD hook. It should not modify the packet. The return value should be the amount of time (in milliseconds) Wintab should wait before pro¬cess¬ing the mes¬sage. This time can be computed by calculation the difference between the time stamps of the current and previous packets. If the function returns zero, the message is processed immediately. Once it returns control to Wintab, the packet continues to be processed. If the nCode parameter is WTHC_SKIP, the hook func-tion should prepare to return the next recorded event message on its next call. The packet pointed to by lParam will have the same structure as packets re¬trieved from the context normally. Wintab will validate the following packet items to en¬sure consistency: context handle, time stamp, and serial number. The remaining fields will be valid if the context used for playback is equivalent to the context from which the events were recorded. The WTH_PLAYBACK hook will not be called to notify it of the display or re¬moval of system modal dialog boxes. It is expected that applications playing back packets will also be playing back window event messages using Windows' own hook functions. While the WTH_PLAYBACK function is in effect, Wintab ignores all hardware in-put. WTH_RECORD The interface calls the WTH_RECORD hook whenever it processes a packet from a context event queue. The hook can be used to record the packet for later playback. The hook function must have attributes equivalent to WINAPI. The hook function must have the following form: Hook Function LRESULT WINAPI HookFunc(nCode, wParam, lParam); int nCode; WPARAM wParam; LPARAM lParam; HookFunc is a place holder for the library-supplied function name. The actual name must be exported by including it in an EXPORTS statement in the library's mod¬ule-definition file. Parameter Description nCode Specifies whether the hook function should process the mes¬sage or call the WTMgrPacketHookDefProc (if installed by WTMgrPacketHook)or WTMgrPacketHookNext (if installed by WTMgrPacketHookEx) function. If the nCode parame¬ter is less than zero, the hook function should pass the message to the appropriate function without further process¬ing. wParam Specifies the context handle whose event is being processed. lParam Points to the packet being processed by the hook function. Comments The WTH_RECORD function should save a copy of the packet for later play¬back. It should not modify the packet. Once it returns control to Wintab, the message con-tinues to be processed. The filter function does not require a return value. The packet pointed to by lParam will have the same structure as packets re¬trieved from the context normally. The WTH_RECORD hook will not be called to notify it of the display or re¬moval of system modal dialog boxes. It is expected that applications recording packets will also be recording window event messages using Windows' own hook functions. 5.8.3 WTMgrPacketUnhook Syntax BOOL WTMgrPacketUnhook(hHook) This function removes a hook function installed by the WTMgrPacketHookEx function. Parameter Type/Description hHook HWTHOOK Identifies the hook function to be removed. Return Value The function returns a non-zero value if successful, zero otherwise. See Also The WTMgrPacketHookEx function in section 5.8.2, and the WTMgrPack-etHookNext function in section 5.8.5. 5.8.4 WTMgrPacketHookDefProc (16-bit only) Syntax LRESULT WTMgrPacketHookDefProc(nCode, wParam, lParam, lplpFunc) This function calls the next function in a chain of packet hook functions. A packet hook function is a function that processes packets before they are re¬trieved from a context's queue. When applications define more than one hook function by using the WTMgrPacketHook function, Wintab places func¬tions of the same type in a chain. Parameter Type/Description nCode int Specifies a code used by the hook function to determine how to process the message. wParam WPARAM Specifies the word parameter of the message that the hook function is processing. lParam LPARAM Specifies the long parameter of the message that the hook function is processing. lplpFunc WTHOOKPROC FAR * Points to a memory location that con-tains the WTHOOKPROC returned by the WTMgrPacketHook function. Wintab changes the value at this location after an appli-cation unhooks the hook using the WTMgrPacketHook function. Return Value The return value specifies a value that is directly related to the nCode parameter. Comments This function is non-portable and is superseded by the WTMgrPacketHookNext function. See Also The WTMgrPacketHookNext function in section 5.8.5. 5.8.5 WTMgrPacketHookNext Syntax LRESULT WTMgrPacketHookNext(hHook, nCode, wParam, lParam) This function passes the hook information to the next hook function in the current hook chain. Parameter Type/Description hHook HWTHOOK Identifies the current hook. nCode int Specifies the hook code passed to the current hook function. wParam WPARAM Specifies the wParam value
stdafx.h的代码// This is a part of the Microsoft Foundation Classes C++ library. // Copyright (C) 1992-1998 Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Microsoft Foundation Classes Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Microsoft Foundation Classes product. #ifndef __AFXWIN_H__ #ifndef RC_INVOKED #define __AFXWIN_H__ ///////////////////////////////////////////////////////////////////////////// // Make sure 'afx.h' is included first #ifndef __AFX_H__ #include #endif // Note: WINDOWS.H already included from AFXV_W32.H #ifndef _INC_SHELLAPI #include #endif #ifndef __AFXRES_H__ #include // standard resource IDs #endif #ifndef __AFXCOLL_H__ #include // standard collections #endif #ifdef _AFX_MINREBUILD #pragma component(minrebuild, off) #endif #ifndef _AFX_FULLTYPEINFO #pragma component(mintypeinfo, on) #endif #ifndef _AFX_NOFORCE_LIBS #pragma comment(lib, "uuid.lib") #endif #ifdef _INC_WINDOWSX // The following names from WINDOWSX.H collide with names in this header #undef SubclassWindow #undef CopyRgn #endif #ifdef _AFX_PACKING #pragma pack(push, _AFX_PACKING) #endif ///////////////////////////////////////////////////////////////////////////// // Classes declared in this file class CSize; class CPoint; class CRect; //CObject //CException //CSimpleException class CResourceException;// Win resource failure exception class CUserException; // Message Box alert and stop operation class CGdiObject; // CDC drawing tool class CPen; // a pen / HPEN wrapper class CBrush; // a brush / HBRUSH wrapper class CFont; // a font / HFONT wrapper class CBitmap; // a bitmap / HBITMAP wrapper class CPalette; // a palette / HPALLETE wrapper class CRgn; // a region / HRGN wrapper class CDC; // a Display Context / HDC wrapper class CClientDC; // CDC for client of window class CWindowDC; // CDC for entire window class CPaintDC; // embeddable BeginPaint struct helper class CMenu; // a menu / HMENU wrapper class CCmdTarget; // a target for user commands class CWnd; // a window / HWND wrapper class CDialog; // a dialog // standard windows controls class CStatic; // Static control class CButton; // Button control class CListBox; // ListBox control class CCheckListBox;// special listbox with checks class CComboBox; // ComboBox control class CEdit; // Edit control class CScrollBar; // ScrollBar control // frame windows class CFrameWnd; // standard SDI frame class CMDIFrameWnd; // standard MDI frame class CMDIChildWnd; // standard MDI child class CMiniFrameWnd;// half-height caption frame wnd // views on a document class CView; // a view on a document class CScrollView; // a scrolling view class CWinThread; // thread base class class CWinApp; // application base class class CDocTemplate; // template for document creation class CSingleDocTemplate;// SDI support class CMultiDocTemplate; // MDI support class CDocument; // main document abstraction // Helper classes class CCmdUI; // Menu/button enabling class CDataExchange; // Data exchange and validation context class CCommandLineInfo; // CommandLine parsing helper class CDocManager; // CDocTemplate manager object ///////////////////////////////////////////////////////////////////////////// // Type modifier for message handlers #ifndef afx_msg #define afx_msg // intentional placeholder #endif #undef AFX_DATA #define AFX_DATA AFX_CORE_DATA ///////////////////////////////////////////////////////////////////////////// // CSize - An extent, similar to Windows SIZE structure. class CSize : public tagSIZE { public: // Constructors // construct an uninitialized size CSize(); // create from two integers CSize(int initCX, int initCY); // create from another size CSize(SIZE initSize); // create from a point CSize(POINT initPt); // create from a DWORD: cx = LOWORD(dw) cy = HIWORD(dw) CSize(DWORD dwSize); // Operations BOOL operator==(SIZE size) const; BOOL operator!=(SIZE size) const; void operator+=(SIZE size); void operator-=(SIZE size); // Operators returning CSize values CSize operator+(SIZE size) const; CSize operator-(SIZE size) const; CSize operator-() const; // Operators returning CPoint values CPoint operator+(POINT point) const; CPoint operator-(POINT point) const; // Operators returning CRect values CRect operator+(const RECT* lpRect) const; CRect operator-(const RECT* lpRect) const; }; ///////////////////////////////////////////////////////////////////////////// // CPoint - A 2-D point, similar to Windows POINT structure. class CPoint : public tagPOINT { public: // Constructors // create an uninitialized point CPoint(); // create from two integers CPoint(int initX, int initY); // create from another point CPoint(POINT initPt); // create from a size CPoint(SIZE initSize); // create from a dword: x = LOWORD(dw) y = HIWORD(dw) CPoint(DWORD dwPoint); // Operations // translate the point void Offset(int xOffset, int yOffset); void Offset(POINT point); void Offset(SIZE size); BOOL operator==(POINT point) const; BOOL operator!=(POINT point) const; void operator+=(SIZE size); void operator-=(SIZE size); void operator+=(POINT point); void operator-=(POINT point); // Operators returning CPoint values CPoint operator+(SIZE size) const; CPoint operator-(SIZE size) const; CPoint operator-() const; CPoint operator+(POINT point) const; // Operators returning CSize values CSize operator-(POINT point) const; // Operators returning CRect values CRect operator+(const RECT* lpRect) const; CRect operator-(const RECT* lpRect) const; }; ///////////////////////////////////////////////////////////////////////////// // CRect - A 2-D rectangle, similar to Windows RECT structure. typedef const RECT* LPCRECT; // pointer to read/only RECT class CRect : public tagRECT { public: // Constructors // uninitialized rectangle CRect(); // from left, top, right, and bottom CRect(int l, int t, int r, int b); // copy constructor CRect(const RECT& srcRect); // from a pointer to another rect CRect(LPCRECT lpSrcRect); // from a point and size CRect(POINT point, SIZE size); // from two points CRect(POINT topLeft, POINT bottomRight); // Attributes (in addition to RECT members) // retrieves the width int Width() const; // returns the height int Height() const; // returns the size CSize Size() const; // reference to the top-left point CPoint& TopLeft(); // reference to the bottom-right point CPoint& BottomRight(); // const reference to the top-left point const CPoint& TopLeft() const; // const reference to the bottom-right point const CPoint& BottomRight() const; // the geometric center point of the rectangle CPoint CenterPoint() const; // swap the left and right void SwapLeftRight(); static void SwapLeftRight(LPRECT lpRect); // convert between CRect and LPRECT/LPCRECT (no need for &) operator LPRECT(); operator LPCRECT() const; // returns TRUE if rectangle has no area BOOL IsRectEmpty() const; // returns TRUE if rectangle is at (0,0) and has no area BOOL IsRectNull() const; // returns TRUE if point is within rectangle BOOL PtInRect(POINT point) const; // Operations // set rectangle from left, top, right, and bottom void SetRect(int x1, int y1, int x2, int y2); void SetRect(POINT topLeft, POINT bottomRight); // empty the rectangle void SetRectEmpty(); // copy from another rectangle void CopyRect(LPCRECT lpSrcRect); // TRUE if exactly the same as another rectangle BOOL EqualRect(LPCRECT lpRect) const; // inflate rectangle's width and height without // moving its top or left void InflateRect(int x, int y); void InflateRect(SIZE size); void InflateRect(LPCRECT lpRect); void InflateRect(int l, int t, int r, int b); // deflate the rectangle's width and height without // moving its top or left void DeflateRect(int x, int y); void DeflateRect(SIZE size); void DeflateRect(LPCRECT lpRect); void DeflateRect(int l, int t, int r, int b); // translate the rectangle by moving its top and left void OffsetRect(int x, int y); void OffsetRect(SIZE size); void OffsetRect(POINT point); void NormalizeRect(); // set this rectangle to intersection of two others BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2); // set this rectangle to bounding union of two others BOOL UnionRect(LPCRECT lpRect1, LPCRECT lpRect2); // set this rectangle to minimum of two others BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2); // Additional Operations void operator=(const RECT& srcRect); BOOL operator==(const RECT& rect) const; BOOL operator!=(const RECT& rect) const; void operator+=(POINT point); void operator+=(SIZE size); void operator+=(LPCRECT lpRect); void operator-=(POINT point); void operator-=(SIZE size); void operator-=(LPCRECT lpRect); void operator&=(const RECT& rect); void operator|=(const RECT& rect); // Operators returning CRect values CRect operator+(POINT point) const; CRect operator-(POINT point) const; CRect operator+(LPCRECT lpRect) const; CRect operator+(SIZE size) const; CRect operator-(SIZE size) const; CRect operator-(LPCRECT lpRect) const; CRect operator&(const RECT& rect2) const; CRect operator|(const RECT& rect2) const; CRect MulDiv(int nMultiplier, int nDivisor) const; }; #ifdef _DEBUG // Diagnostic Output CDumpContext& AFXAPI operator<<(CDumpContext& dc, SIZE size); CDumpContext& AFXAPI operator<<(CDumpContext& dc, POINT point); CDumpContext& AFXAPI operator<<(CDumpContext& dc, const RECT& rect); #endif //_DEBUG // Serialization CArchive& AFXAPI operator<<(CArchive& ar, SIZE size); CArchive& AFXAPI operator<<(CArchive& ar, POINT point); CArchive& AFXAPI operator<>(CArchive& ar, SIZE& size); CArchive& AFXAPI operator>>(CArchive& ar, POINT& point); CArchive& AFXAPI operator>>(CArchive& ar, RECT& rect); ///////////////////////////////////////////////////////////////////////////// // Standard exceptions class CResourceException : public CSimpleException // resource failure { DECLARE_DYNAMIC(CResourceException) public: CResourceException(); // Implementation public: CResourceException(BOOL bAutoDelete); CResourceException(BOOL bAutoDelete, UINT nResourceID); virtual ~CResourceException(); }; class CUserException : public CSimpleException // general user visible alert { DECLARE_DYNAMIC(CUserException) public: CUserException(); // Implementation public: CUserException(BOOL bAutoDelete); CUserException(BOOL bAutoDelete, UINT nResourceID); virtual ~CUserException(); }; void AFXAPI AfxThrowResourceException(); void AFXAPI AfxThrowUserException(); ///////////////////////////////////////////////////////////////////////////// // CGdiObject abstract class for CDC SelectObject class CGdiObject : public CObject { DECLARE_DYNCREATE(CGdiObject) public: // Attributes HGDIOBJ m_hObject; // must be first data member operator HGDIOBJ() const; HGDIOBJ GetSafeHandle() const; static CGdiObject* PASCAL FromHandle(HGDIOBJ hObject); static void PASCAL DeleteTempMap(); BOOL Attach(HGDIOBJ hObject); HGDIOBJ Detach(); // Constructors CGdiObject(); // must Create a derived class object BOOL DeleteObject(); // Operations int GetObject(int nCount, LPVOID lpObject) const; UINT GetObjectType() const; BOOL CreateStockObject(int nIndex); BOOL UnrealizeObject(); BOOL operator==(const CGdiObject& obj) const; BOOL operator!=(const CGdiObject& obj) const; // Implementation public: virtual ~CGdiObject(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; virtual void AssertValid() const; #endif }; ///////////////////////////////////////////////////////////////////////////// // CGdiObject subclasses (drawing tools) class CPen : public CGdiObject { DECLARE_DYNAMIC(CPen) public: static CPen* PASCAL FromHandle(HPEN hPen); // Constructors CPen(); CPen(int nPenStyle, int nWidth, COLORREF crColor); CPen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush, int nStyleCount = 0, const DWORD* lpStyle = NULL); BOOL CreatePen(int nPenStyle, int nWidth, COLORREF crColor); BOOL CreatePen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush, int nStyleCount = 0, const DWORD* lpStyle = NULL); BOOL CreatePenIndirect(LPLOGPEN lpLogPen); // Attributes operator HPEN() const; int GetLogPen(LOGPEN* pLogPen); int GetExtLogPen(EXTLOGPEN* pLogPen); // Implementation public: virtual ~CPen(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; #endif }; class CBrush : public CGdiObject { DECLARE_DYNAMIC(CBrush) public: static CBrush* PASCAL FromHandle(HBRUSH hBrush); // Constructors CBrush(); CBrush(COLORREF crColor); // CreateSolidBrush CBrush(int nIndex, COLORREF crColor); // CreateHatchBrush CBrush(CBitmap* pBitmap); // CreatePatternBrush BOOL CreateSolidBrush(COLORREF crColor); BOOL CreateHatchBrush(int nIndex, COLORREF crColor); BOOL CreateBrushIndirect(const LOGBRUSH* lpLogBrush); BOOL CreatePatternBrush(CBitmap* pBitmap); BOOL CreateDIBPatternBrush(HGLOBAL hPackedDIB, UINT nUsage); BOOL CreateDIBPatternBrush(const void* lpPackedDIB, UINT nUsage); BOOL CreateSysColorBrush(int nIndex); // Attributes operator HBRUSH() const; int GetLogBrush(LOGBRUSH* pLogBrush); // Implementation public: virtual ~CBrush(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; #endif }; class CFont : public CGdiObject { DECLARE_DYNAMIC(CFont) public: static CFont* PASCAL FromHandle(HFONT hFont); // Constructors CFont(); BOOL CreateFontIndirect(const LOGFONT* lpLogFont); BOOL CreateFont(int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily, LPCTSTR lpszFacename); BOOL CreatePointFont(int nPointSize, LPCTSTR lpszFaceName, CDC* pDC = NULL); BOOL CreatePointFontIndirect(const LOGFONT* lpLogFont, CDC* pDC = NULL); // Attributes operator HFONT() const; int GetLogFont(LOGFONT* pLogFont); // Implementation public: virtual ~CFont(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; #endif }; class CBitmap : public CGdiObject { DECLARE_DYNAMIC(CBitmap) public: static CBitmap* PASCAL FromHandle(HBITMAP hBitmap); // Constructors CBitmap(); BOOL LoadBitmap(LPCTSTR lpszResourceName); BOOL LoadBitmap(UINT nIDResource); BOOL LoadOEMBitmap(UINT nIDBitmap); // for OBM_/OCR_/OIC_ BOOL LoadMappedBitmap(UINT nIDBitmap, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL, int nMapSize = 0); BOOL CreateBitmap(int nWidth, int nHeight, UINT nPlanes, UINT nBitcount, const void* lpBits); BOOL CreateBitmapIndirect(LPBITMAP lpBitmap); BOOL CreateCompatibleBitmap(CDC* pDC, int nWidth, int nHeight); BOOL CreateDiscardableBitmap(CDC* pDC, int nWidth, int nHeight); // Attributes operator HBITMAP() const; int GetBitmap(BITMAP* pBitMap); // Operations DWORD SetBitmapBits(DWORD dwCount, const void* lpBits); DWORD GetBitmapBits(DWORD dwCount, LPVOID lpBits) const; CSize SetBitmapDimension(int nWidth, int nHeight); CSize GetBitmapDimension() const; // Implementation public: virtual ~CBitmap(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; #endif }; class CPalette : public CGdiObject { DECLARE_DYNAMIC(CPalette) public: static CPalette* PASCAL FromHandle(HPALETTE hPalette); // Constructors CPalette(); BOOL CreatePalette(LPLOGPALETTE lpLogPalette); BOOL CreateHalftonePalette(CDC* pDC); // Attributes operator HPALETTE() const; int GetEntryCount(); UINT GetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors) const; UINT SetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors); // Operations void AnimatePalette(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors); UINT GetNearestPaletteIndex(COLORREF crColor) const; BOOL ResizePalette(UINT nNumEntries); // Implementation virtual ~CPalette(); }; class CRgn : public CGdiObject { DECLARE_DYNAMIC(CRgn) public: static CRgn* PASCAL FromHandle(HRGN hRgn); operator HRGN() const; // Constructors CRgn(); BOOL CreateRectRgn(int x1, int y1, int x2, int y2); BOOL CreateRectRgnIndirect(LPCRECT lpRect); BOOL CreateEllipticRgn(int x1, int y1, int x2, int y2); BOOL CreateEllipticRgnIndirect(LPCRECT lpRect); BOOL CreatePolygonRgn(LPPOINT lpPoints, int nCount, int nMode); BOOL CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount, int nPolyFillMode); BOOL CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3); BOOL CreateFromPath(CDC* pDC); BOOL CreateFromData(const XFORM* lpXForm, int nCount, const RGNDATA* pRgnData); // Operations void SetRectRgn(int x1, int y1, int x2, int y2); void SetRectRgn(LPCRECT lpRect); int CombineRgn(CRgn* pRgn1, CRgn* pRgn2, int nCombineMode); int CopyRgn(CRgn* pRgnSrc); BOOL EqualRgn(CRgn* pRgn) const; int OffsetRgn(int x, int y); int OffsetRgn(POINT point); int GetRgnBox(LPRECT lpRect) const; BOOL PtInRegion(int x, int y) const; BOOL PtInRegion(POINT point) const; BOOL RectInRegion(LPCRECT lpRect) const; int GetRegionData(LPRGNDATA lpRgnData, int nCount) const; // Implementation virtual ~CRgn(); }; ///////////////////////////////////////////////////////////////////////////// // The device context class CDC : public CObject { DECLARE_DYNCREATE(CDC) public: // Attributes HDC m_hDC; // The output DC (must be first data member) HDC m_hAttribDC; // The Attribute DC operator HDC() const; HDC GetSafeHdc() const; // Always returns the Output DC CWnd* GetWindow() const; static CDC* PASCAL FromHandle(HDC hDC); static void PASCAL DeleteTempMap(); BOOL Attach(HDC hDC); // Attach/Detach affects only the Output DC HDC Detach(); virtual void SetAttribDC(HDC hDC); // Set the Attribute DC virtual void SetOutputDC(HDC hDC); // Set the Output DC virtual void ReleaseAttribDC(); // Release the Attribute DC virtual void ReleaseOutputDC(); // Release the Output DC BOOL IsPrinting() const; // TRUE if being used for printing CPen* GetCurrentPen() const; CBrush* GetCurrentBrush() const; CPalette* GetCurrentPalette() const; CFont* GetCurrentFont() const; CBitmap* GetCurrentBitmap() const; // for bidi and mirrored localization DWORD GetLayout() const; DWORD SetLayout(DWORD dwLayout); // Constructors CDC(); BOOL CreateDC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName, LPCTSTR lpszOutput, const void* lpInitData); BOOL CreateIC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName, LPCTSTR lpszOutput, const void* lpInitData); BOOL CreateCompatibleDC(CDC* pDC); BOOL DeleteDC(); // Device-Context Functions virtual int SaveDC(); virtual BOOL RestoreDC(int nSavedDC); int GetDeviceCaps(int nIndex) const; UINT SetBoundsRect(LPCRECT lpRectBounds, UINT flags); UINT GetBoundsRect(LPRECT lpRectBounds, UINT flags); BOOL ResetDC(const DEVMODE* lpDevMode); // Drawing-Tool Functions CPoint GetBrushOrg() const; CPoint SetBrushOrg(int x, int y); CPoint SetBrushOrg(POINT point); int EnumObjects(int nObjectType, int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData); // Type-safe selection helpers public: virtual CGdiObject* SelectStockObject(int nIndex); CPen* SelectObject(CPen* pPen); CBrush* SelectObject(CBrush* pBrush); virtual CFont* SelectObject(CFont* pFont); CBitmap* SelectObject(CBitmap* pBitmap); int SelectObject(CRgn* pRgn); // special return for regions CGdiObject* SelectObject(CGdiObject* pObject); // CGdiObject* provided so compiler doesn't use SelectObject(HGDIOBJ) // Color and Color Palette Functions COLORREF GetNearestColor(COLORREF crColor) const; CPalette* SelectPalette(CPalette* pPalette, BOOL bForceBackground); UINT RealizePalette(); void UpdateColors(); // Drawing-Attribute Functions COLORREF GetBkColor() const; int GetBkMode() const; int GetPolyFillMode() const; int GetROP2() const; int GetStretchBltMode() const; COLORREF GetTextColor() const; virtual COLORREF SetBkColor(COLORREF crColor); int SetBkMode(int nBkMode); int SetPolyFillMode(int nPolyFillMode); int SetROP2(int nDrawMode); int SetStretchBltMode(int nStretchMode); virtual COLORREF SetTextColor(COLORREF crColor); BOOL GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust) const; BOOL SetColorAdjustment(const COLORADJUSTMENT* lpColorAdjust); // Mapping Functions int GetMapMode() const; CPoint GetViewportOrg() const; virtual int SetMapMode(int nMapMode); // Viewport Origin virtual CPoint SetViewportOrg(int x, int y); CPoint SetViewportOrg(POINT point); virtual CPoint OffsetViewportOrg(int nWidth, int nHeight); // Viewport Extent CSize GetViewportExt() const; virtual CSize SetViewportExt(int cx, int cy); CSize SetViewportExt(SIZE size); virtual CSize ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom); // Window Origin CPoint GetWindowOrg() const; CPoint SetWindowOrg(int x, int y); CPoint SetWindowOrg(POINT point); CPoint OffsetWindowOrg(int nWidth, int nHeight); // Window extent CSize GetWindowExt() const; virtual CSize SetWindowExt(int cx, int cy); CSize SetWindowExt(SIZE size); virtual CSize ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom); // Coordinate Functions void DPtoLP(LPPOINT lpPoints, int nCount = 1) const; void DPtoLP(LPRECT lpRect) const; void DPtoLP(LPSIZE lpSize) const; void LPtoDP(LPPOINT lpPoints, int nCount = 1) const; void LPtoDP(LPRECT lpRect) const; void LPtoDP(LPSIZE lpSize) const; // Special Coordinate Functions (useful for dealing with metafiles and OLE) void DPtoHIMETRIC(LPSIZE lpSize) const; void LPtoHIMETRIC(LPSIZE lpSize) const; void HIMETRICtoDP(LPSIZE lpSize) const; void HIMETRICtoLP(LPSIZE lpSize) const; // Region Functions BOOL FillRgn(CRgn* pRgn, CBrush* pBrush); BOOL FrameRgn(CRgn* pRgn, CBrush* pBrush, int nWidth, int nHeight); BOOL InvertRgn(CRgn* pRgn); BOOL PaintRgn(CRgn* pRgn); // Clipping Functions virtual int GetClipBox(LPRECT lpRect) const; virtual BOOL PtVisible(int x, int y) const; BOOL PtVisible(POINT point) const; virtual BOOL RectVisible(LPCRECT lpRect) const; int SelectClipRgn(CRgn* pRgn); int ExcludeClipRect(int x1, int y1, int x2, int y2); int ExcludeClipRect(LPCRECT lpRect); int ExcludeUpdateRgn(CWnd* pWnd); int IntersectClipRect(int x1, int y1, int x2, int y2); int IntersectClipRect(LPCRECT lpRect); int OffsetClipRgn(int x, int y); int OffsetClipRgn(SIZE size); int SelectClipRgn(CRgn* pRgn, int nMode); // Line-Output Functions CPoint GetCurrentPosition() const; CPoint MoveTo(int x, int y); CPoint MoveTo(POINT point); BOOL LineTo(int x, int y); BOOL LineTo(POINT point); BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd); BOOL Polyline(LPPOINT lpPoints, int nCount); BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle); BOOL ArcTo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd); int GetArcDirection() const; int SetArcDirection(int nArcDirection); BOOL PolyDraw(const POINT* lpPoints, const BYTE* lpTypes, int nCount); BOOL PolylineTo(const POINT* lpPoints, int nCount); BOOL PolyPolyline(const POINT* lpPoints, const DWORD* lpPolyPoints, int nCount); BOOL PolyBezier(const POINT* lpPoints, int nCount); BOOL PolyBezierTo(const POINT* lpPoints, int nCount); // Simple Drawing Functions void FillRect(LPCRECT lpRect, CBrush* pBrush); void FrameRect(LPCRECT lpRect, CBrush* pBrush); void InvertRect(LPCRECT lpRect); BOOL DrawIcon(int x, int y, HICON hIcon); BOOL DrawIcon(POINT point, HICON hIcon); #if (WINVER >= 0x400) BOOL DrawState(CPoint pt, CSize size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush = NULL); BOOL DrawState(CPoint pt, CSize size, CBitmap* pBitmap, UINT nFlags, CBrush* pBrush = NULL); BOOL DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags, HBRUSH hBrush = NULL); BOOL DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags, CBrush* pBrush = NULL); BOOL DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText = TRUE, int nTextLen = 0, HBRUSH hBrush = NULL); BOOL DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText = TRUE, int nTextLen = 0, CBrush* pBrush = NULL); BOOL DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, HBRUSH hBrush = NULL); BOOL DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, CBrush* pBrush = NULL); #endif // Ellipse and Polygon Functions BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); BOOL Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd); void DrawFocusRect(LPCRECT lpRect); BOOL Ellipse(int x1, int y1, int x2, int y2); BOOL Ellipse(LPCRECT lpRect); BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd); BOOL Polygon(LPPOINT lpPoints, int nCount); BOOL PolyPolygon(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount); BOOL Rectangle(int x1, int y1, int x2, int y2); BOOL Rectangle(LPCRECT lpRect); BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3); BOOL RoundRect(LPCRECT lpRect, POINT point); // Bitmap Functions BOOL PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop); BOOL BitBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, DWORD dwRop); BOOL StretchBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop); COLORREF GetPixel(int x, int y) const; COLORREF GetPixel(POINT point) const; COLORREF SetPixel(int x, int y, COLORREF crColor); COLORREF SetPixel(POINT point, COLORREF crColor); BOOL FloodFill(int x, int y, COLORREF crColor); BOOL ExtFloodFill(int x, int y, COLORREF crColor, UINT nFillType); BOOL MaskBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, CBitmap& maskBitmap, int xMask, int yMask, DWORD dwRop); BOOL PlgBlt(LPPOINT lpPoint, CDC* pSrcDC, int xSrc, int ySrc, int nWidth, int nHeight, CBitmap& maskBitmap, int xMask, int yMask); BOOL SetPixelV(int x, int y, COLORREF crColor); BOOL SetPixelV(POINT point, COLORREF crColor); // Text Functions virtual BOOL TextOut(int x, int y, LPCTSTR lpszString, int nCount); BOOL TextOut(int x, int y, const CString& str); virtual BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, UINT nCount, LPINT lpDxWidths); BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, const CString& str, LPINT lpDxWidths); virtual CSize TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin); CSize TabbedTextOut(int x, int y, const CString& str, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin); virtual int DrawText(LPCTSTR lpszString, int nCount, LPRECT lpRect, UINT nFormat); int DrawText(const CString& str, LPRECT lpRect, UINT nFormat); CSize GetTextExtent(LPCTSTR lpszString, int nCount) const; CSize GetTextExtent(const CString& str) const; CSize GetOutputTextExtent(LPCTSTR lpszString, int nCount) const; CSize GetOutputTextExtent(const CString& str) const; CSize GetTabbedTextExtent(LPCTSTR lpszString, int nCount, int nTabPositions, LPINT lpnTabStopPositions) const; CSize GetTabbedTextExtent(const CString& str, int nTabPositions, LPINT lpnTabStopPositions) const; CSize GetOutputTabbedTextExtent(LPCTSTR lpszString, int nCount, int nTabPositions, LPINT lpnTabStopPositions) const; CSize GetOutputTabbedTextExtent(const CString& str, int nTabPositions, LPINT lpnTabStopPositions) const; virtual BOOL GrayString(CBrush* pBrush, BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM, int), LPARAM lpData, int nCount, int x, int y, int nWidth, int nHeight); UINT GetTextAlign() const; UINT SetTextAlign(UINT nFlags); int GetTextFace(int nCount, LPTSTR lpszFacename) const; int GetTextFace(CString& rString) const; BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics) const; BOOL GetOutputTextMetrics(LPTEXTMETRIC lpMetrics) const; int SetTextJustification(int nBreakExtra, int nBreakCount); int GetTextCharacterExtra() const; int SetTextCharacterExtra(int nCharExtra); // Advanced Drawing #if (WINVER >= 0x400) BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags); BOOL DrawFrameControl(LPRECT lpRect, UINT nType, UINT nState); #endif // Scrolling Functions BOOL ScrollDC(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, CRgn* pRgnUpdate, LPRECT lpRectUpdate); // Font Functions BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const; BOOL GetOutputCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const; DWORD SetMapperFlags(DWORD dwFlag); CSize GetAspectRatioFilter() const; BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABC lpabc) const; DWORD GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData) const; int GetKerningPairs(int nPairs, LPKERNINGPAIR lpkrnpair) const; UINT GetOutlineTextMetrics(UINT cbData, LPOUTLINETEXTMETRIC lpotm) const; DWORD GetGlyphOutline(UINT nChar, UINT nFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpBuffer, const MAT2* lpmat2) const; BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABCFLOAT lpABCF) const; BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, float* lpFloatBuffer) const; // Printer/Device Escape Functions virtual int Escape(int nEscape, int nCount, LPCSTR lpszInData, LPVOID lpOutData); int Escape(int nEscape, int nInputSize, LPCSTR lpszInputData, int nOutputSize, LPSTR lpszOutputData); int DrawEscape(int nEscape, int nInputSize, LPCSTR lpszInputData); // Escape helpers int StartDoc(LPCTSTR lpszDocName); // old Win3.0 version int StartDoc(LPDOCINFO lpDocInfo); int StartPage(); int EndPage(); int SetAbortProc(BOOL (CALLBACK* lpfn)(HDC, int)); int AbortDoc(); int EndDoc(); // MetaFile Functions BOOL PlayMetaFile(HMETAFILE hMF); BOOL PlayMetaFile(HENHMETAFILE hEnhMetaFile, LPCRECT lpBounds); BOOL AddMetaFileComment(UINT nDataSize, const BYTE* pCommentData); // can be used for enhanced metafiles only // Path Functions BOOL AbortPath(); BOOL BeginPath(); BOOL CloseFigure(); BOOL EndPath(); BOOL FillPath(); BOOL FlattenPath(); BOOL StrokeAndFillPath(); BOOL StrokePath(); BOOL WidenPath(); float GetMiterLimit() const; BOOL SetMiterLimit(float fMiterLimit); int GetPath(LPPOINT lpPoints, LPBYTE lpTypes, int nCount) const; BOOL SelectClipPath(int nMode); // Misc Helper Functions static CBrush* PASCAL GetHalftoneBrush(); void DrawDragRect(LPCRECT lpRect, SIZE size, LPCRECT lpRectLast, SIZE sizeLast, CBrush* pBrush = NULL, CBrush* pBrushLast = NULL); void FillSolidRect(LPCRECT lpRect, COLORREF clr); void FillSolidRect(int x, int y, int cx, int cy, COLORREF clr); void Draw3dRect(LPCRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight); void Draw3dRect(int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight); // Implementation public: virtual ~CDC(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif // advanced use and implementation BOOL m_bPrinting; HGDIOBJ SelectObject(HGDIOBJ); // do not use for regions protected: // used for implementation of non-virtual SelectObject calls static CGdiObject* PASCAL SelectGdiObject(HDC hDC, HGDIOBJ h); }; ///////////////////////////////////////////////////////////////////////////// // CDC Helpers class CPaintDC : public CDC { DECLARE_DYNAMIC(CPaintDC) // Constructors public: CPaintDC(CWnd* pWnd); // BeginPaint // Attributes protected: HWND m_hWnd; public: PAINTSTRUCT m_ps; // actual paint struct! // Implementation public: virtual ~CPaintDC(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; class CClientDC : public CDC { DECLARE_DYNAMIC(CClientDC) // Constructors public: CClientDC(CWnd* pWnd); // Attributes protected: HWND m_hWnd; // Implementation public: virtual ~CClientDC(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; class CWindowDC : public CDC { DECLARE_DYNAMIC(CWindowDC) // Constructors public: CWindowDC(CWnd* pWnd); // Attributes protected: HWND m_hWnd; // Implementation public: virtual ~CWindowDC(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; ///////////////////////////////////////////////////////////////////////////// // CMenu class CMenu : public CObject { DECLARE_DYNCREATE(CMenu) public: // Constructors CMenu(); BOOL CreateMenu(); BOOL CreatePopupMenu(); BOOL LoadMenu(LPCTSTR lpszResourceName); BOOL LoadMenu(UINT nIDResource); BOOL LoadMenuIndirect(const void* lpMenuTemplate); BOOL DestroyMenu(); // Attributes HMENU m_hMenu; // must be first data member HMENU GetSafeHmenu() const; operator HMENU() const; static CMenu* PASCAL FromHandle(HMENU hMenu); static void PASCAL DeleteTempMap(); BOOL Attach(HMENU hMenu); HMENU Detach(); // CMenu Operations BOOL DeleteMenu(UINT nPosition, UINT nFlags); BOOL TrackPopupMenu(UINT nFlags, int x, int y, CWnd* pWnd, LPCRECT lpRect = 0); BOOL operator==(const CMenu& menu) const; BOOL operator!=(const CMenu& menu) const; // CMenuItem Operations BOOL AppendMenu(UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL); BOOL AppendMenu(UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp); UINT CheckMenuItem(UINT nIDCheckItem, UINT nCheck); UINT EnableMenuItem(UINT nIDEnableItem, UINT nEnable); UINT GetMenuItemCount() const; UINT GetMenuItemID(int nPos) const; UINT GetMenuState(UINT nID, UINT nFlags) const; int GetMenuString(UINT nIDItem, LPTSTR lpString, int nMaxCount, UINT nFlags) const; int GetMenuString(UINT nIDItem, CString& rString, UINT nFlags) const; BOOL GetMenuItemInfo(UINT nIDItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos = FALSE); CMenu* GetSubMenu(int nPos) const; BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL); BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp); BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL); BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp); BOOL RemoveMenu(UINT nPosition, UINT nFlags); BOOL SetMenuItemBitmaps(UINT nPosition, UINT nFlags, const CBitmap* pBmpUnchecked, const CBitmap* pBmpChecked); BOOL CheckMenuRadioItem(UINT nIDFirst, UINT nIDLast, UINT nIDItem, UINT nFlags); BOOL SetDefaultItem(UINT uItem, BOOL fByPos = FALSE); UINT GetDefaultItem(UINT gmdiFlags, BOOL fByPos = FALSE); // Context Help Functions BOOL SetMenuContextHelpId(DWORD dwContextHelpId); DWORD GetMenuContextHelpId() const; // Overridables (must override draw and measure for owner-draw menu items) virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); // Implementation public: virtual ~CMenu(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif static CMenu* PASCAL CMenu::FromHandlePermanent(HMENU hMenu); }; ///////////////////////////////////////////////////////////////////////////// // Window message map handling struct AFX_MSGMAP_ENTRY; // declared below after CWnd struct AFX_MSGMAP { #ifdef _AFXDLL const AFX_MSGMAP* (PASCAL* pfnGetBaseMap)(); #else const AFX_MSGMAP* pBaseMap; #endif const AFX_MSGMAP_ENTRY* lpEntries; }; #ifdef _AFXDLL #define DECLARE_MESSAGE_MAP() \ private: \ static const AFX_MSGMAP_ENTRY _messageEntries[]; \ protected: \ static AFX_DATA const AFX_MSGMAP messageMap; \ static const AFX_MSGMAP* PASCAL _GetBaseMessageMap(); \ virtual const AFX_MSGMAP* GetMessageMap() const; \ #else #define DECLARE_MESSAGE_MAP() \ private: \ static const AFX_MSGMAP_ENTRY _messageEntries[]; \ protected: \ static AFX_DATA const AFX_MSGMAP messageMap; \ virtual const AFX_MSGMAP* GetMessageMap() const; \ #endif #ifdef _AFXDLL #define BEGIN_MESSAGE_MAP(theClass, baseClass) \ const AFX_MSGMAP* PASCAL theClass::_GetBaseMessageMap() \ { return &baseClass;::messageMap; } \ const AFX_MSGMAP* theClass::GetMessageMap() const \ { return &theClass;::messageMap; } \ AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \ { &theClass;::_GetBaseMessageMap, &theClass;::_messageEntries[0] }; \ AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \ { \ #else #define BEGIN_MESSAGE_MAP(theClass, baseClass) \ const AFX_MSGMAP* theClass::GetMessageMap() const \ { return &theClass;::messageMap; } \ AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \ { &baseClass;::messageMap, &theClass;::_messageEntries[0] }; \ AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \ { \ #endif #define END_MESSAGE_MAP() \ {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } \ }; \ // Message map signature values and macros in separate header #include ///////////////////////////////////////////////////////////////////////////// // Dialog data exchange (DDX_) and validation (DDV_) // CDataExchange - for data exchange and validation class CDataExchange { // Attributes public: BOOL m_bSaveAndValidate; // TRUE => save and validate data CWnd* m_pDlgWnd; // container usually a dialog // Operations (for implementors of DDX and DDV procs) HWND PrepareCtrl(int nIDC); // return HWND of control HWND PrepareEditCtrl(int nIDC); // return HWND of control void Fail(); // will throw exception #ifndef _AFX_NO_OCC_SUPPORT CWnd* PrepareOleCtrl(int nIDC); // for OLE controls in dialog #endif // Implementation CDataExchange(CWnd* pDlgWnd, BOOL bSaveAndValidate); HWND m_hWndLastControl; // last control used (for validation) BOOL m_bEditLastControl; // last control was an edit item }; #include // standard DDX_ and DDV_ routines ///////////////////////////////////////////////////////////////////////////// // OLE types typedef LONG HRESULT; struct IUnknown; typedef IUnknown* LPUNKNOWN; struct IDispatch; typedef IDispatch* LPDISPATCH; struct IConnectionPoint; typedef IConnectionPoint* LPCONNECTIONPOINT; struct IEnumOLEVERB; typedef IEnumOLEVERB* LPENUMOLEVERB; typedef struct _GUID GUID; typedef GUID IID; typedef GUID CLSID; #ifndef _REFCLSID_DEFINED #define REFCLSID const CLSID & #endif typedef long DISPID; typedef unsigned short VARTYPE; typedef long SCODE; #if defined(WIN32) && !defined(OLE2ANSI) typedef WCHAR OLECHAR; #else typedef char OLECHAR; #endif typedef OLECHAR* BSTR; struct tagDISPPARAMS; typedef tagDISPPARAMS DISPPARAMS; struct tagVARIANT; typedef tagVARIANT VARIANT; struct ITypeInfo; typedef ITypeInfo* LPTYPEINFO; struct ITypeLib; typedef ITypeLib* LPTYPELIB; ///////////////////////////////////////////////////////////////////////////// // CCmdTarget // private structures struct AFX_CMDHANDLERINFO; // info about where the command is handled struct AFX_EVENT; // info about an event class CTypeLibCache; // cache for OLE type libraries ///////////////////////////////////////////////////////////////////////////// // OLE interface map handling (more in AFXDISP.H) #ifndef _AFX_NO_OLE_SUPPORT struct AFX_INTERFACEMAP_ENTRY { const void* piid; // the interface id (IID) (NULL for aggregate) size_t nOffset; // offset of the interface vtable from m_unknown }; struct AFX_INTERFACEMAP { #ifdef _AFXDLL const AFX_INTERFACEMAP* (PASCAL* pfnGetBaseMap)(); // NULL is root class #else const AFX_INTERFACEMAP* pBaseMap; #endif const AFX_INTERFACEMAP_ENTRY* pEntry; // map for this class }; #ifdef _AFXDLL #define DECLARE_INTERFACE_MAP() \ private: \ static const AFX_INTERFACEMAP_ENTRY _interfaceEntries[]; \ protected: \ static AFX_DATA const AFX_INTERFACEMAP interfaceMap; \ static const AFX_INTERFACEMAP* PASCAL _GetBaseInterfaceMap(); \ virtual const AFX_INTERFACEMAP* GetInterfaceMap() const; \ #else #define DECLARE_INTERFACE_MAP() \ private: \ static const AFX_INTERFACEMAP_ENTRY _interfaceEntries[]; \ protected: \ static AFX_DATA const AFX_INTERFACEMAP interfaceMap; \ virtual const AFX_INTERFACEMAP* GetInterfaceMap() const; \ #endif #endif //!_AFX_NO_OLE_SUPPORT ///////////////////////////////////////////////////////////////////////////// // OLE dispatch map handling (more in AFXDISP.H) #ifndef _AFX_NO_OLE_SUPPORT struct AFX_DISPMAP_ENTRY; struct AFX_DISPMAP { #ifdef _AFXDLL const AFX_DISPMAP* (PASCAL* pfnGetBaseMap)(); #else const AFX_DISPMAP* pBaseMap; #endif const AFX_DISPMAP_ENTRY* lpEntries; UINT* lpEntryCount; DWORD* lpStockPropMask; }; #ifdef _AFXDLL #define DECLARE_DISPATCH_MAP() \ private: \ static const AFX_DISPMAP_ENTRY _dispatchEntries[]; \ static UINT _dispatchEntryCount; \ static DWORD _dwStockPropMask; \ protected: \ static AFX_DATA const AFX_DISPMAP dispatchMap; \ static const AFX_DISPMAP* PASCAL _GetBaseDispatchMap(); \ virtual const AFX_DISPMAP* GetDispatchMap() const; \ #else #define DECLARE_DISPATCH_MAP() \ private: \ static const AFX_DISPMAP_ENTRY _dispatchEntries[]; \ static UINT _dispatchEntryCount; \ static DWORD _dwStockPropMask; \ protected: \ static AFX_DATA const AFX_DISPMAP dispatchMap; \ virtual const AFX_DISPMAP* GetDispatchMap() const; \ #endif #endif //!_AFX_NO_OLE_SUPPORT ///////////////////////////////////////////////////////////////////////////// // OLE Document Object command target handling #ifndef _AFX_NO_DOCOBJECT_SUPPORT struct AFX_OLECMDMAP_ENTRY { const GUID* pguid; // id of the command group ULONG cmdID; // OLECMD ID UINT nID; // corresponding WM_COMMAND message ID }; struct AFX_OLECMDMAP { #ifdef _AFXDLL const AFX_OLECMDMAP* (PASCAL* pfnGetBaseMap)(); #else const AFX_OLECMDMAP* pBaseMap; #endif const AFX_OLECMDMAP_ENTRY* lpEntries; }; #ifdef _AFXDLL #define DECLARE_OLECMD_MAP() \ private: \ static const AFX_OLECMDMAP_ENTRY _commandEntries[]; \ protected: \ static AFX_DATA const AFX_OLECMDMAP commandMap; \ static const AFX_OLECMDMAP* PASCAL _GetBaseCommandMap(); \ virtual const AFX_OLECMDMAP* GetCommandMap() const; \ #else #define DECLARE_OLECMD_MAP() \ private: \ static const AFX_OLECMDMAP_ENTRY _commandEntries[]; \ protected: \ static AFX_DATA const AFX_OLECMDMAP commandMap; \ virtual const AFX_OLECMDMAP* GetCommandMap() const; \ #endif #ifdef _AFXDLL #define BEGIN_OLECMD_MAP(theClass, baseClass) \ const AFX_OLECMDMAP* PASCAL theClass::_GetBaseCommandMap() \ { return &baseClass;::commandMap; } \ const AFX_OLECMDMAP* theClass::GetCommandMap() const \ { return &theClass;::commandMap; } \ AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \ { &theClass;::_GetBaseCommandMap, &theClass;::_commandEntries[0] }; \ AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \ { \ #else #define BEGIN_OLECMD_MAP(theClass, baseClass) \ const AFX_OLECMDMAP* theClass::GetCommandMap() const \ { return &theClass;::commandMap; } \ AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \ { &baseClass;::commandMap, &theClass;::_commandEntries[0] }; \ AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \ { \ #endif #define END_OLECMD_MAP() \ {NULL, 0, 0} \ }; \ class COleCmdUI; #endif //!_AFX_NO_DOCOBJECT_SUPPORT ///////////////////////////////////////////////////////////////////////////// // OLE event sink map handling (more in AFXDISP.H) #ifndef _AFX_NO_OCC_SUPPORT struct AFX_EVENTSINKMAP_ENTRY; struct AFX_EVENTSINKMAP { #ifdef _AFXDLL const AFX_EVENTSINKMAP* (PASCAL* pfnGetBaseMap)(); #else const AFX_EVENTSINKMAP* pBaseMap; #endif const AFX_EVENTSINKMAP_ENTRY* lpEntries; UINT* lpEntryCount; }; #ifdef _AFXDLL #define DECLARE_EVENTSINK_MAP() \ private: \ static const AFX_EVENTSINKMAP_ENTRY _eventsinkEntries[]; \ static UINT _eventsinkEntryCount; \ protected: \ static AFX_DATA const AFX_EVENTSINKMAP eventsinkMap; \ static const AFX_EVENTSINKMAP* PASCAL _GetBaseEventSinkMap(); \ virtual const AFX_EVENTSINKMAP* GetEventSinkMap() const; \ #else #define DECLARE_EVENTSINK_MAP() \ private: \ static const AFX_EVENTSINKMAP_ENTRY _eventsinkEntries[]; \ static UINT _eventsinkEntryCount; \ protected: \ static AFX_DATA const AFX_EVENTSINKMAP eventsinkMap; \ virtual const AFX_EVENTSINKMAP* GetEventSinkMap() const; \ #endif #endif //!_AFX_NO_OCC_SUPPORT ///////////////////////////////////////////////////////////////////////////// // OLE connection map handling (more in AFXDISP.H) #ifndef _AFX_NO_OLE_SUPPORT struct AFX_CONNECTIONMAP_ENTRY { const void* piid; // the interface id (IID) size_t nOffset; // offset of the interface vtable from m_unknown }; struct AFX_CONNECTIONMAP { #ifdef _AFXDLL const AFX_CONNECTIONMAP* (PASCAL* pfnGetBaseMap)(); // NULL is root class #else const AFX_CONNECTIONMAP* pBaseMap; #endif const AFX_CONNECTIONMAP_ENTRY* pEntry; // map for this class }; #ifdef _AFXDLL #define DECLARE_CONNECTION_MAP() \ private: \ static const AFX_CONNECTIONMAP_ENTRY _connectionEntries[]; \ protected: \ static AFX_DATA const AFX_CONNECTIONMAP connectionMap; \ static const AFX_CONNECTIONMAP* PASCAL _GetBaseConnectionMap(); \ virtual const AFX_CONNECTIONMAP* GetConnectionMap() const; \ #else #define DECLARE_CONNECTION_MAP() \ private: \ static const AFX_CONNECTIONMAP_ENTRY _connectionEntries[]; \ protected: \ static AFX_DATA const AFX_CONNECTIONMAP connectionMap; \ virtual const AFX_CONNECTIONMAP* GetConnectionMap() const; \ #endif #endif //!_AFX_NO_OLE_SUPPORT ///////////////////////////////////////////////////////////////////////////// // CCmdTarget proper #ifndef _AFX_NO_OCC_SUPPORT class COccManager; // forward reference (see ..\src\occimpl.h) #endif #ifdef _AFXDLL class CCmdTarget : public CObject #else class AFX_NOVTABLE CCmdTarget : public CObject #endif { DECLARE_DYNAMIC(CCmdTarget) protected: public: // Constructors CCmdTarget(); // Attributes LPDISPATCH GetIDispatch(BOOL bAddRef); // retrieve IDispatch part of CCmdTarget static CCmdTarget* PASCAL FromIDispatch(LPDISPATCH lpDispatch); // map LPDISPATCH back to CCmdTarget* (inverse of GetIDispatch) BOOL IsResultExpected(); // returns TRUE if automation function should return a value // Operations void EnableAutomation(); // call in constructor to wire up IDispatch void EnableConnections(); // call in constructor to wire up IConnectionPointContainer void BeginWaitCursor(); void EndWaitCursor(); void RestoreWaitCursor(); // call after messagebox #ifndef _AFX_NO_OLE_SUPPORT // dispatch OLE verbs through the message map BOOL EnumOleVerbs(LPENUMOLEVERB* ppenumOleVerb); BOOL DoOleVerb(LONG iVerb, LPMSG lpMsg, HWND hWndParent, LPCRECT lpRect); #endif // Overridables // route and dispatch standard command message types // (more sophisticated than OnCommand) virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); #ifndef _AFX_NO_OLE_SUPPORT // called when last OLE reference is released virtual void OnFinalRelease(); #endif #ifndef _AFX_NO_OLE_SUPPORT // called before dispatching to an automation handler function virtual BOOL IsInvokeAllowed(DISPID dispid); #endif #ifndef _AFX_NO_OLE_SUPPORT // support for OLE type libraries void EnableTypeLib(); HRESULT GetTypeInfoOfGuid(LCID lcid, const GUID& guid, LPTYPEINFO* ppTypeInfo); virtual BOOL GetDispatchIID(IID* pIID); virtual UINT GetTypeInfoCount(); virtual CTypeLibCache* GetTypeLibCache(); virtual HRESULT GetTypeLib(LCID lcid, LPTYPELIB* ppTypeLib); #endif // Implementation public: virtual ~CCmdTarget(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; virtual void AssertValid() const; #endif #ifndef _AFX_NO_OLE_SUPPORT void GetNotSupported(); void SetNotSupported(); #endif protected: friend class CView; CView* GetRoutingView(); CFrameWnd* GetRoutingFrame(); static CView* PASCAL GetRoutingView_(); static CFrameWnd* PASCAL GetRoutingFrame_(); DECLARE_MESSAGE_MAP() // base class - no {{ }} macros #ifndef _AFX_NO_DOCOBJECT_SUPPORT DECLARE_OLECMD_MAP() friend class COleCmdUI; #endif #ifndef _AFX_NO_OLE_SUPPORT DECLARE_DISPATCH_MAP() DECLARE_CONNECTION_MAP() DECLARE_INTERFACE_MAP() #ifndef _AFX_NO_OCC_SUPPORT DECLARE_EVENTSINK_MAP() #endif // !_AFX_NO_OCC_SUPPORT // OLE interface map implementation public: // data used when CCmdTarget is made OLE aware long m_dwRef; LPUNKNOWN m_pOuterUnknown; // external controlling unknown if != NULL DWORD m_xInnerUnknown; // place-holder for inner controlling unknown public: // advanced operations void EnableAggregation(); // call to enable aggregation void ExternalDisconnect(); // forcibly disconnect LPUNKNOWN GetControllingUnknown(); // get controlling IUnknown for aggregate creation // these versions do not delegate to m_pOuterUnknown DWORD InternalQueryInterface(const void*, LPVOID* ppvObj); DWORD InternalAddRef(); DWORD InternalRelease(); // these versions delegate to m_pOuterUnknown DWORD ExternalQueryInterface(const void*, LPVOID* ppvObj); DWORD ExternalAddRef(); DWORD ExternalRelease(); // implementation helpers LPUNKNOWN GetInterface(const void*); LPUNKNOWN QueryAggregates(const void*); // advanced overrideables for implementation virtual BOOL OnCreateAggregates(); virtual LPUNKNOWN GetInterfaceHook(const void*); // OLE automation implementation protected: struct XDispatch { DWORD m_vtbl; // place-holder for IDispatch vtable #ifndef _AFX_NO_NESTED_DERIVATION size_t m_nOffset; #endif } m_xDispatch; BOOL m_bResultExpected; // member variable-based properties void GetStandardProp(const AFX_DISPMAP_ENTRY* pEntry, VARIANT* pvarResult, UINT* puArgErr); SCODE SetStandardProp(const AFX_DISPMAP_ENTRY* pEntry, DISPPARAMS* pDispParams, UINT* puArgErr); // DISPID to dispatch map lookup static UINT PASCAL GetEntryCount(const AFX_DISPMAP* pDispMap); const AFX_DISPMAP_ENTRY* PASCAL GetDispEntry(LONG memid); static LONG PASCAL MemberIDFromName(const AFX_DISPMAP* pDispMap, LPCTSTR lpszName); // helpers for member function calling implementation static UINT PASCAL GetStackSize(const BYTE* pbParams, VARTYPE vtResult); #ifdef _PPC_ SCODE PushStackArgs(BYTE* pStack, const BYTE* pbParams, void* pResult, VARTYPE vtResult, DISPPARAMS* pDispParams, UINT* puArgErr, VARIANT* rgTempVars, UINT nSizeArgs); #else SCODE PushStackArgs(BYTE* pStack, const BYTE* pbParams, void* pResult, VARTYPE vtResult, DISPPARAMS* pDispParams, UINT* puArgErr, VARIANT* rgTempVars); #endif SCODE CallMemberFunc(const AFX_DISPMAP_ENTRY* pEntry, WORD wFlags, VARIANT* pvarResult, DISPPARAMS* pDispParams, UINT* puArgErr); friend class COleDispatchImpl; #ifndef _AFX_NO_OCC_SUPPORT public: // OLE event sink implementation BOOL OnEvent(UINT idCtrl, AFX_EVENT* pEvent, AFX_CMDHANDLERINFO* pHandlerInfo); protected: const AFX_EVENTSINKMAP_ENTRY* PASCAL GetEventSinkEntry(UINT idCtrl, AFX_EVENT* pEvent); #endif // !_AFX_NO_OCC_SUPPORT // OLE connection implementation struct XConnPtContainer { DWORD m_vtbl; // place-holder for IConnectionPointContainer vtable #ifndef _AFX_NO_NESTED_DERIVATION size_t m_nOffset; #endif } m_xConnPtContainer; #ifdef _AFXDLL AFX_MODULE_STATE* m_pModuleState; friend class CInnerUnknown; friend UINT APIENTRY _AfxThreadEntry(void* pParam); #endif virtual BOOL GetExtraConnectionPoints(CPtrArray* pConnPoints); virtual LPCONNECTIONPOINT GetConnectionHook(const IID& iid); friend class COleConnPtContainer; #endif //!_AFX_NO_OLE_SUPPORT }; class CCmdUI // simple helper class { public: // Attributes UINT m_nID; UINT m_nIndex; // menu item or other index // if a menu item CMenu* m_pMenu; // NULL if not a menu CMenu* m_pSubMenu; // sub containing menu item // if a popup sub menu - ID is for first in popup // if from some other window CWnd* m_pOther; // NULL if a menu or not a CWnd // Operations to do in ON_UPDATE_COMMAND_UI virtual void Enable(BOOL bOn = TRUE); virtual void SetCheck(int nCheck = 1); // 0, 1 or 2 (indeterminate) virtual void SetRadio(BOOL bOn = TRUE); virtual void SetText(LPCTSTR lpszText); // Advanced operation void ContinueRouting(); // Implementation CCmdUI(); BOOL m_bEnableChanged; BOOL m_bContinueRouting; UINT m_nIndexMax; // last + 1 for iterating m_nIndex CMenu* m_pParentMenu; // NULL if parent menu not easily determined // (probably a secondary popup menu) BOOL DoUpdate(CCmdTarget* pTarget, BOOL bDisableIfNoHndler); }; // special CCmdUI derived classes are used for other UI paradigms // like toolbar buttons and status indicators // pointer to afx_msg member function #ifndef AFX_MSG_CALL #define AFX_MSG_CALL #endif typedef void (AFX_MSG_CALL CCmdTarget::*AFX_PMSG)(void); enum AFX_DISPMAP_FLAGS { afxDispCustom = 0, afxDispStock = 1 }; struct AFX_DISPMAP_ENTRY { LPCTSTR lpszName; // member/property name long lDispID; // DISPID (may be DISPID_UNKNOWN) LPCSTR lpszParams; // member parameter description WORD vt; // return value type / or type of property AFX_PMSG pfn; // normal member On or, OnGet AFX_PMSG pfnSet; // special member for OnSet size_t nPropOffset; // property offset AFX_DISPMAP_FLAGS flags;// flags (e.g. stock/custom) }; struct AFX_EVENTSINKMAP_ENTRY { AFX_DISPMAP_ENTRY dispEntry; UINT nCtrlIDFirst; UINT nCtrlIDLast; }; // DSC Sink state/reason codes passed to MFC user event handlers enum DSCSTATE { dscNoState = 0, dscOKToDo, dscCancelled, dscSyncBefore, dscAboutToDo, dscFailedToDo, dscSyncAfter, dscDidEvent }; enum DSCREASON { dscNoReason = 0, dscClose, dscCommit, dscDelete, dscEdit, dscInsert, dscModify, dscMove }; ///////////////////////////////////////////////////////////////////////////// // CWnd implementation // structures (see afxext.h) struct CCreateContext; // context for creating things struct CPrintInfo; // print preview customization info struct AFX_MSGMAP_ENTRY { UINT nMessage; // windows message UINT nCode; // control code or WM_NOTIFY code UINT nID; // control ID (or 0 for windows messages) UINT nLastID; // used for entries specifying a range of control id's UINT nSig; // signature type (action) or pointer to message # AFX_PMSG pfn; // routine to call (or special value) }; ///////////////////////////////////////////////////////////////////////////// // CWnd - a Microsoft Windows application window class COleDropTarget; // for more information see AFXOLE.H class COleControlContainer; class COleControlSite; // CWnd::m_nFlags (generic to CWnd) #define WF_TOOLTIPS 0x0001 // window is enabled for tooltips #define WF_TEMPHIDE 0x0002 // window is temporarily hidden #define WF_STAYDISABLED 0x0004 // window should stay disabled #define WF_MODALLOOP 0x0008 // currently in modal loop #define WF_CONTINUEMODAL 0x0010 // modal loop should continue running #define WF_OLECTLCONTAINER 0x0100 // some descendant is an OLE control #define WF_TRACKINGTOOLTIPS 0x0400 // window is enabled for tracking tooltips // CWnd::m_nFlags (specific to CFrameWnd) #define WF_STAYACTIVE 0x0020 // look active even though not active #define WF_NOPOPMSG 0x0040 // ignore WM_POPMESSAGESTRING calls #define WF_MODALDISABLE 0x0080 // window is disabled #define WF_KEEPMINIACTIVE 0x0200 // stay activate even though you are deactivated // flags for CWnd::RunModalLoop #define ML

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧