After the two pieces of code in a creat move effective but it is invalid in the WM_SIZE move
case WM_CREATE message handler:
for(i=0; i{
Hwndscroll [I]=CreateWindow (TEXT (" scrollbar "), NULL,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | SBS_VERT,
0,0,0,0, HWND, (HMENU) I, hinstance, NULL);
SB_CTL SetScrollRange (hwndscroll [I], 0255, false);
SB_CTL SetScrollPos (hwndscroll [I], 0, false);
MoveWindow (hwndscroll [I], 0, 0,
10100, true);
}
return 0;
/* case WM_SIZE:
MoveWindow (hwndscroll [I], 0, 0,
10100, true);
return 0; */
The effective
Case WM_CREATE message handler:
for(i=0; i{
Hwndscroll [I]=CreateWindow (TEXT (" scrollbar "), NULL,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | SBS_VERT,
0,0,0,0, HWND, (HMENU) I, hinstance, NULL);
SB_CTL SetScrollRange (hwndscroll [I], 0255, false);
SB_CTL SetScrollPos (hwndscroll [I], 0, false);
/* MoveWindow (hwndscroll [I], 0, 0,
10100, true); */
}
return 0;
Case WM_SIZE:
MoveWindow (hwndscroll [I], 0, 0,
10100, true);
return 0;
The invalid
Seek the solution
All the code below
//win32-0. CPP: defines the entry point of application,
//
# include "stdafx. H"
# include & lt; Windows. H>
# define NUM 1
LRESULT a CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
Int idfocus;
Int WINAPI WinMain (HINSTANCE HINSTANCE,
HINSTANCE hPrevInstance,
PSTR szCmdLine,
Int iCmdShow)
{
The static TCHAR szAppName []=TEXT (" HelloWin ");
The HWND HWND;//window handle
MSG MSG.//message structure
WNDCLASS WNDCLASS;//window class structure
Wndclass. Style=CS_HREDRAW | CS_VREDRAW;
Wndclass. LpfnWndProc=WndProc;
Wndclass. CbClsExtra=0;
Wndclass. CbWndExtra=0;
Wndclass. HInstance=hInstance;
Wndclass. HIcon=LoadIcon (NULL, IDI_APPLICATION);//load the icon for the use of program
Wndclass. HCursor=LoadCursor (NULL, IDC_ARROW);//load the mouse pointer for the use of program
Wndclass. HbrBackground=(HBRUSH) GetStockObject (WHITE_BRUSH);//get a graphics object, in this case, is to obtain a brush for painting the background of the window
Wndclass. LpszMenuName=NULL;
Wndclass. LpszClassName=szAppName;
if (! RegisterClass (& amp; Wndclass))//as a registered window class program window
{
MessageBox (NULL, TEXT (" This program requires Windows NT!" ),
SzAppName, MB_ICONERROR);
Return 0;
}
//in accordance with the window class to create a window
HWND=CreateWindow (szAppName,//the window class name
The TEXT (" The Hello Program "),//window caption
WS_OVERLAPPEDWINDOW,//the window style
CW_USEDEFAULT,//initial position x
CW_USEDEFAULT,//initial position y
CW_USEDEFAULT,//initial size x
CW_USEDEFAULT,//initial y size
NULL,//the parent window handle
Window menu handle NULL,//
HInstance,//program instance handle
NULL);//creation parameters
ShowWindow (HWND, iCmdShow);//on the screen window
UpdateWindow (HWND);//instructions window updates its
While (GetMessage (& amp; MSG, NULL, 0, 0))//get messages from the message queue
{
TranslateMessage (& amp; MSG);//convert some keyboard message
DispatchMessage (& amp; MSG);//the message is sent to the window procedure
}
Return MSG. WParam;
}
LRESULT a CALLBACK WndProc (HWND HWND, UINT message, WPARAM WPARAM, LPARAM LPARAM)
{
HDC HDC.
PAINTSTRUCT ps;
The RECT the RECT.
The static HWND hwndscroll (NUM);
Static int I;
Static int cxclient cyclient;
Static int cychar;
HINSTANCE HINSTANCE,
Hinstance=(hinstance) GetWindowLong (HWND, GWL_HINSTANCE);
The switch (the message)
{
Case WM_CREATE message handler:
for(i=0; i{
Hwndscroll [I]=CreateWindow (TEXT (" scrollbar "), NULL,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | SBS_VERT,
0,0,0,0, HWND, (HMENU) I, hinstance, NULL);
SB_CTL SetScrollRange (hwndscroll [I], 0255, false);
SB_CTL SetScrollPos (hwndscroll [I], 0, false);
/* MoveWindow (hwndscroll [I], 0, 0,
10100, true); */
}
return 0;
Case WM_SIZE:
MoveWindow (hwndscroll [I], 0, 0,
10100, true);
return 0;
Case WM_DESTROY:
The PostQuitMessage (0);//in the message queue insert an "exit" message
Return 0;
}
Return DefWindowProc (HWND, message, wParam, lParam);//the default message processing
}
/* LRESULT CALLBACK scrollproc (HWND HWND, UINT message, WPARAM WPARAM, LPARAM LPARAM)
{
The switch (the message)
{
Case WM_DESTROY:
The PostQuitMessage (0);
return 0;
}
Return DefWindowProc (HWND, message, wParam, lParam);//the default message processing
} */
CodePudding user response:
Ooops the code above is wrongThis is the
//win32-0. CPP: defines the entry point of application,
//
# include "stdafx. H"
# include & lt; Windows. H>
# define NUM 1
LRESULT a CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
Int idfocus;
Int WINAPI WinMain (HINSTANCE HINSTANCE,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull