Home > Software engineering >  [WINAPI] WINAPI development in the superclass when the window, please don't create the problem
[WINAPI] WINAPI development in the superclass when the window, please don't create the problem

Time:10-06

This is the last time the TAB interface switch a problem, because eventually failed to have a suitable plan and decided to try the super class, because it is the only way of dealing with the WM_CREATE message handler.
The code
 # pragma once 
# include "framework. H"
HINSTANCE UIHINST
HWND=HWND;
WNDPROC EXTTOLD;
Typedef struct tagEXT
{//
HWND=HWND;//handle of the owner window
BOOL x1;//default is 185
BOOL y1.//default is 170
BOOL x2.
BOOL y2.
HBRUSH style;
UINT styleU;
WNDPROC lpfnWndProc;
Int cbClsExtra;
Int cbWndExtra;
HINSTANCE HINSTANCE,
HICON HICON;
HCURSOR HCURSOR;
LPCWSTR lpszMenuName;
LPCWSTR lpszClassName;
} EXT_PARAM;
//static would m_strInput XFFFFF [0]=L "";//declare variables input box
# define IDS_TEXT1 0 x200
# define IDB_BT1 0 x199
LRESULT a CALLBACK EXTUIProc (HWND HWND, UINT message, WPARAM WPARAM, LPARAM LPARAM)//STR=WCS, must be converted to Unicode
{

//the RECT rc;
//char prompt [40].
//int len=wcslen (m_strInput);
The switch (the message)
{

Case WM_CREATE message handler:
{
MessageBox (0, L "when you see this message, it shows that the window to create a success", "L" super class ", 0).
break;
}
break;
Default:
break;
}

Return CallWindowProc (EXTUIProc HWND, message, wParam, lParam);
}


Int EXTUI (
The HWND HWND,//handle of the owner window
BOOL x1,
BOOL y1,
BOOL x2,
BOOL y2
//LPWSTR in,
)
{
Modifed WNDCLASSEX extwindow;
: : GetClassInfoEx (hInstance, L "extwin", & amp; Extwindow);
//save the original controls the default message handler
EXTTOLD=extwindow. LpfnWndProc;
//set to replace message processing function
Extwindow. LpfnWndProc=EXTUIProc;
//specify the new window class name
Extwindow. LpszClassName=L "extwindow";
//set the structure size
Extwindow. CbSize=sizeof (modifed WNDCLASSEX);
//register new information
RegisterClassEx (& amp; Extwindow);
//modifed WNDCLASSEX wndclass={0};
The static HFONT HFONT;
UIHINST=hInstance;
CON_PARAM BTN={0};
BTN. HWnd=hWnd;

HWND=CreateWindowEx (NULL, extwindow lpszClassName, L "EXTUI,"
WS_CHILD, x1, y1, x2, y2, HWND, NULL, hInstance, 0);

ShowWindow (HWND, SW_SHOW);
UpdateWindow (hWnd);

//return 0;
return -1;
}

In the main window after
 EXTUI (x, y, RCX, rcy);//show 

The above code, to achieve a child window.
But as the chart

The child window has not been completely created!
All code, what is the mistake?

CodePudding user response:

BOOL x1;//default is 185
BOOL y1.//default is 170
BOOL x2.
BOOL y2.
Why is a BOOL?

CodePudding user response:

HWND=CreateWindowEx (NULL, extwindow lpszClassName, L "EXTUI,"
WS_CHILD, x1, y1, x2, y2, HWND hParentWnd, NULL, hInstance, 0);

CodePudding user response:

//Win32Tab. CPP: Defines the entry point for the application. The
//

# include "stdafx. H"
# include "resource. H"

# define MAX_LOADSTRING 100

//Global Variables:
HINSTANCE hInst,//the current instance
TCHAR szTitle [MAX_LOADSTRING];//The title bar text
TCHAR szWindowClass [MAX_LOADSTRING];//The title bar text
//
# define PAGES 3
The HWND g_pages [PAGES];
Int g_PageNow=0;
The HWND g_btn1;
The HWND g_btn2;
//Foward declarations of functions provides the included this code in the module:
The ATOM MyRegisterClass (HINSTANCE HINSTANCE);
BOOL InitInstance (HINSTANCE, int);
LRESULT a CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT a CALLBACK About (HWND, UINT, WPARAM, LPARAM);

Int APIENTRY WinMain (HINSTANCE HINSTANCE,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
Int nCmdShow)
{
//TODO: Place code here.
MSG MSG.
HACCEL hAccelTable;

//Initialize global strings
LoadString (hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString (hInstance, IDC_WIN32TAB, szWindowClass, MAX_LOADSTRING);
MyRegisterClass (hInstance);

//Perform application initialization:
if (! InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

HAccelTable=LoadAccelerators (hInstance, LPCTSTR IDC_WIN32TAB);

//the Main message loop:
While (GetMessage (& amp; MSG, NULL, 0, 0))
{
if (! TranslateAccelerator (MSG. The HWND hAccelTable, & amp; MSG))
{
TranslateMessage (& amp; MSG);
DispatchMessage (& amp; MSG);
}
}

Return MSG. WParam;
}
# define MainWidth 100
//
BOOL CALLBACK PageProc1 (HWND hwndDlg, UINT uMsg, WPARAM WPARAM, LPARAM LPARAM)
{
The RECT rc;
HDC HDC.
HBRUSH br;
//POINT pt;
//char prompt [40].
//
The switch (uMsg)
{
Case WM_INITDIALOG:
GetClientRect (hwndDlg, & amp; Rc);
Rc. Left +=MainWidth;
Rc. Right +=MainWidth;
MoveWindow (hwndDlg, rc. Left, rc. Top, rc, right - rc. Left, rc. The bottom - rc. Top, TRUE);
return TRUE;
Case WM_ERASEBKGND:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related