Home > Back-end >  Would you please tell me why the program of slider can not stop in one place
Would you please tell me why the program of slider can not stop in one place

Time:09-26

//win32-0. CPP: defines the entry point of application, 
//

# include "stdafx. H"
# include & lt; Windows. H>

LRESULT a CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT a CALLBACK scrollpro (HWND, UINT, WPARAM, LPARAM);
Int idfocus;
WNDPROC oldscoll [3].
Static int color [3], cychar;



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 COLORREF crprim [3]={RGB (0, 255), RGB (0255, 0), RGB (0,0,255)};
The static HBRUSH HBRUSH [3], hbrushstatic;
Hwndlabel static HWND hwndscroll [3], [3], hwndvalue [3], hwndrect;

The static the RECT rccolor;
The static TCHAR * szcolorlabel []={TEXT (" RED "), TEXT (" GREEN "), TEXT (" BLUE ")};//text - & gt; Reason for unicode unable to initialize the char array pointer
HINSTANCE HINSTANCE,//a pointer to the instance
Int I, cxclient cyclient;
TCHAR szbuffer [10].//wide character buffer to temporary color value

The switch (the message)
{

Case WM_CREATE message handler:
Hinstance=(hinstance) GetWindowLong (HWND, GWL_HINSTANCE);
Hwndrect=CreateWindow (TEXT (" static "), NULL,
WS_CHILD | WS_VISIBLE | SS_WHITERECT,
0,0,0,0, HWND, (HMENU) 9, hinstance, NULL);
for(i=0; i<3; 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);

Hwndlabel [I]=CreateWindow (TEXT (" static "), szcolorlabel [I],
WS_VISIBLE | WS_CHILD | SS_CENTER, 0,0,0,0,
The HWND, (HMENU) (I + 3), hinstance, NULL);
Oldscoll [I]=(WNDPROC) SetWindowLong (hwndscroll [I], GWL_WNDPROC, (LONG) scrollpro);
//to find the scroll bar window function pointer! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

}
Hbrushstatic=CreateSolidBrush (GetSysColor (COLOR_BTNHIGHLIGHT));
Hbrush [I]=CreateSolidBrush (crprim [I]);
Cychar=HIWORD (GetDialogBaseUnits ());
return 0;
Case WM_SIZE:
Cxclient=LOWORD (lParam);
Cyclient=HIWORD (lParam);
SetRect (& amp; Rccolor cxclient/2, 0, cxclient, cyclient);
MoveWindow (hwndrect, 0, 0, cxclient/2, cyclient, true);
for(i=0; i<3; I++)
{
MoveWindow (hwndscroll [I],
I + 1) (2 * * cxclient/14, 2 * cychar,
Cxclient/14, cyclient - 4, true);
MoveWindow (hwndlabel [I],
(4 * I + 1) * cxclient/28, cychar/2,
Cxclient/7, cychar, true);
MoveWindow (hwndvalue [I],
(4 * I + 1) * cxclient/28,
Cyclient cychar/2-3 *,
Cxclient/7, cychar, true);
}
SetFocus (HWND);
return 0;
/* case WM_SETFOCUS:
SetFocus (hwndscroll [idfocus]);
return 0; */
Case WM_VSCROLL:
I=GetWindowLong (lParam (HWND), GWL_ID);//the child window ID
The switch (LOWORD (lParam))
{
Case SB_PAGEDOWN:
Color [I] +=15;
break;
Case SB_LINEDOWN:
Color [I] +=1;
break;
Case SB_PAGEUP:
Color - [I]=15;
break;
Case SB_LINEUP:
Color - [I]=1;
break;
Case SB_TOP:
Color [I]=0;
break;
Case SB_BOTTOM:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related