Has this problem, because I really can't solve the problem of no response of the edit control, want to do an edit control, but because use it there will be a lot of places in the program, so worried that there is a custom edit controls window procedure chaos disturbance, CodePudding user response:
Example: Similar window.//CPP: Defines the entry point for the console application. // #include //hide the console window # pragma comment (would, "/subsystem: \ Windows \ mainCRTStartup"/entry: \ "" ") # define WM_SETIMAGE WM_APP + 1 HINSTANCE HINSTANCE, HWND hwndT0=0, hwndT1=0, hwndT2=0, hwndT3=0; HBITMAP hbmpT0=0, hbmpT1=0, hbmpT2=0, hbmpT3=0; Int g_WinNum=0; // LRESULT a CALLBACK WindowProc (HWND HWND, UINT uMsg, WPARAM WPARAM, LPARAM LPARAM) { HDC hmemDC; HBITMAP hbmpOld; HDC HDC. The RECT rc; HBITMAP hbmpTmp; Int nWindth; Int nHeight; POINT pt; Char * fileName. Char TXT [10]. PAINTSTRUCT ps; The switch (uMsg) { In case the WM_PAINT: HDC=BeginPaint (HWND, & amp; Ps); // GetClientRect (HWND, & amp; Rc); NWindth=rc. Right - rc. Left; NHeight=rc. Bottom - rc. Top; HmemDC=CreateCompatibleDC (HDC); // SetBkMode (HDC, TRANSPARENT); If (HWND==hwndT0) { If (hbmpT0) { HbmpOld=(HBITMAP) SelectObject (hmemDC hbmpT0); Strcpy (TXT, "Test0"); } } Else if (HWND==hwndT1) { If (hbmpT1) { HbmpOld=(HBITMAP) SelectObject (hmemDC hbmpT1); Strcpy (TXT, "Test1"); } } Else if (HWND==hwndT2) { If (hbmpT2) { HbmpOld=(HBITMAP) SelectObject (hmemDC hbmpT2); Strcpy (TXT, "Test2"); } } Else if (HWND==hwndT3) { If (hbmpT3) { HbmpOld=(HBITMAP) SelectObject (hmemDC hbmpT3); Strcpy (TXT, "Test3"); } } //the draw SetStretchBltMode (HDC, HALFTONE); StretchBlt (HDC, 0, 0, nWindth, nHeight, hmemDC, 0,0,200,200, SRCCOPY); //text TextOut (HDC, 0, 0, TXT, strlen ()); //free SelectObject (hmemDC hbmpOld); EndPaint (HWND, & amp; Ps); return 0; Case WM_SETIMAGE: FileName=lParam (char *); HbmpTmp=(HBITMAP) : : LoadImage (NULL, fileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); If (HWND==hwndT0) { HbmpT0=hbmpTmp; } Else if (HWND==hwndT1) { HbmpT1=hbmpTmp; } Else if (HWND==hwndT2) { HbmpT2=hbmpTmp; } Else if (HWND==hwndT3) { HbmpT3=hbmpTmp; } return 0; Case WM_SETCURSOR: GetClientRect (HWND, & amp; Rc); The GetCursorPos (& amp; Pt); ScreenToClient (HWND, & amp; Pt); If (PtInRect (& amp; Rc, pt)) { LParam=HTCLIENT;//arrow } break; Case WM_DESTROY: G_WinNum -; If (g_WinNum==0) PostQuitMessage (0); return 0; } Return DefWindowProc (HWND, uMsg wParam, lParam); } // Void initRegister () { HInstance=GetModuleHandle (NULL); WNDCLASS WNDC; WNDC. CbClsExtra=0; WNDC. CbWndExtra=0; WNDC. HCursor=LoadCursor (hInstance, IDC_ARROW); WNDC. HIcon=LoadIcon (hInstance, IDI_APPLICATION); WNDC. LpszMenuName=NULL; WNDC. Style=CS_HREDRAW | CS_VREDRAW; WNDC. HbrBackground=(COLOR_WINDOW HBRUSH); WNDC. LpfnWndProc=WindowProc; WNDC. LpszClassName="classname"; WNDC. HInstance=hInstance; // RegisterClass (& amp; WNDC); } // The HWND aptly named createWidget (char * name, int x, int y, int width, int height) { HWND HWND=0; HWnd=CreateWindow (" classname ", the name, WS_OVERLAPPEDWINDOW | WS_VISIBLE, X, y, width, height, NULL, NULL,//(HMENU) (int) (ID_FIRSTCHILD + I),=100... HInstance, NULL); // G_WinNum + +; // Return the hWnd; } // Void SetWndImage (HWND HWND, char * fileName)//this is only notification display picture { SendMessage (hWnd, WM_SETIMAGE, 0, (LPARAM) fileName); } // # define ScreenX 240 # define ScreenY 100 Void main () {// InitRegister (); HwndT0=aptly named createWidget (" test0, "ScreenX ScreenY, 300300); SetWndImage (hwndT0, a. "mp"); HwndT1=aptly named createWidget (" test1 ", ScreenX + 300, ScreenY, 300300); B.b mp SetWndImage (hwndT1, ""); //row 2 HwndT2=aptly named createWidget (" test2 ", ScreenX ScreenY + 300300300); SetWndImage (hwndT2, "mount mp"); HwndT3=aptly named createWidget (" test3 ", ScreenX + 300, ScreenY + 300300300); SetWndImage (hwndT3, "db mp"); // MSG MSG. While (GetMessage (& amp; MSG, NULL, 0, 0)) { TranslateMessage (& amp; MSG); nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull