To ask about the help timovjl it is already awkward, but a problem much more above level of my knowledge.
Buttons in StatusBar are, they are pressed and pushed out, but ANYTHING more don't do.
On the Internet and in textbooks almost all examples for StatusBar show only as in it to place the text.
Has found 2 examples which place in StatusBar EditBox and ComboBox.
But these examples again on C ++ they create the classes.
Examples MSDN:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb760726%28v=vs.85%29.aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/bb775583%28v=vs.85%29.aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/bb775494%28v=vs.85%29.aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/bb775941%28v=vs.85%29.aspx as always very foggy, I have altered an example from listView into Buttons - it doesn't work.
Has checked up the most different variants for reception of messages from the created buttons - they don't work.
At me such impression that the program doesn't receive ANYTHING from these buttons.
To dispel doubts, I have moved these buttons from StatusBar in Clien-area of main window. And then all these buttons began to work.
But to allocate for them space in the main window it is impossible - the empty seat isn't present. Therefore all xxxx-CAD systems use for them StatusBar (it practically the standard).
---------------------------------------------------------------------
In func. WndProc() case WM_NOTIFY call CALLBACK WndStatusBar() and I see my debug MessageBox() - NOT more.
Fragments of code:
from main.h
-----------
HWND hwMain; // Main window
HANDLE hLcWnd; // Design window hwndChild2
HANDLE hLcCmd; // Command window hwndChild3
HANDLE hLcProp; // Properties window hwndChild1
HANDLE hLcDrw; // LiteCAD drawing
HWND hwStatBar; // Status bar
HANDLE hView, hBlock, hLayer, hPline, hEnt, hText, hTStyle;
HWND hButton; // Buttons in StatusBar
// Global Variables:
HINSTANCE hInst; // current instance of main window
// ... ... ...
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass (HINSTANCE hInstance);
BOOL InitInstance (HINSTANCE, int);
// ... ... ...
void CALLBACK EventMouseMove (HANDLE hWnd, int Button, int Flags, int Xwin, int Ywin, double X, double Y);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK WndStatusBar(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK Users1(HWND, UINT, WPARAM, LPARAM); // SNK additions
LRESULT Splitter_OnLButtonDown (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
LRESULT Splitter_OnLButtonUp (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
LRESULT Splitter_OnMouseMove (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
from main.c
-----------
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
// ... ... ...
// StatusBar
// hwStatBar = CreateWindow( STATUSCLASSNAME, TEXT("NULL"), WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
// 0,0,60,20, hwMain, (HMENU)101, hInstance, NULL );
hwStatBar = CreateWindowEx( 0, STATUSCLASSNAME, TEXT("NULL"), WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
0,0,60,20, hwMain, (HMENU)101, hInstance, NULL );
if (!hwStatBar){
return FALSE;
}
//SendMessage( hwStatBar, SB_SIMPLE, TRUE, 0 ); // for Simple-mode StatusBar
//SendMessage( <HandleStatusBar>, WM_<COMMAND>, (WPARAM)<CMD-PARAM1>, (LPARAM)<CMD-PARAM2> );
INT Parts[3];
Parts[0] = 290;
//Parts[1] = 10;
Parts[1] = 610;
Parts[2] = -1;
SendMessage (hwStatBar, SB_SETPARTS, (WPARAM)2, (LPARAM)Parts );
/* Create PUSHLIKE AUTOCHECKBOX Buttons in StatusBar */
hButton = CreateWindowEx(0, WC_BUTTON, TEXT("SNAP"),
WS_CHILD | WS_VISIBLE| BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT,
300, 4, 50, 16, hwStatBar, (HMENU)4000, hInstance, NULL);
hButton = CreateWindowEx( 0, WC_BUTTON, TEXT("GRID"),
WS_CHILD | WS_VISIBLE| BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT,
350, 4, 50, 16, hwStatBar, (HMENU)4001, hInstance, NULL );
hButton = CreateWindowEx( 0, WC_BUTTON, TEXT("ORTHO"),
WS_CHILD | WS_VISIBLE| BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT,
400, 4, 50, 16, hwStatBar, (HMENU)4002, hInstance, NULL );
hButton = CreateWindowEx( 0, WC_BUTTON, TEXT("POLAR"),
WS_CHILD | WS_VISIBLE| BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT
, 450, 4, 50, 16, hwStatBar, (HMENU)4003, hInstance, NULL );
hButton = CreateWindowEx( 0, WC_BUTTON, TEXT("OSNAP"),
WS_CHILD | WS_VISIBLE| BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT,
500, 4, 50, 16, hwStatBar, (HMENU)4004, hInstance, NULL );
hButton = CreateWindowEx( 0, WC_BUTTON, TEXT("LWT"),
WS_CHILD | WS_VISIBLE| BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT,
550, 4, 50, 16, hwStatBar, (HMENU)4005, hInstance, NULL );
// ... ... ...
return TRUE;
}
/* end of InitInstance() */
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// ... ... ...
case WM_NOTIFY: // bipass control to callback-function WndStatusBar()
WndStatusBar( hWnd, message, wParam, lParam); break;
break;
// ... ... ...
return 0;
}
/* end of CALLBACK WndProc () - main window processing */
//LRESULT CALLBACK WndStatusBar(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
INT_PTR CALLBACK WndStatusBar(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
MessageBox( NULL, TEXT("... NOW in WndStatusBar ..."), NULL, MB_OK ); // Error-Message
// UNREFERENCED_PARAMETER(lParam);
NMHDR nmh;
nmh.code = NM_CLICK; // Message type defined by control.
nmh.idFrom = GetDlgCtrlID(hWnd);
nmh.hwndFrom = hWnd;
SendMessage( GetParent(hWnd), WM_NOTIFY, (WPARAM)hWnd, (LPARAM)&nmh );
switch (message)
{
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code)
// or lParam)->idFrom = GetDlgCtrlID(m_controlHwnd)
// or lParam)->hwndFrom = m_controlHwnd
{
case NM_CLICK:
if (((LPNMHDR)lParam)->idFrom == IDC_GRID)
{ // Respond to message
SendMessage(hButton, WM_SETFONT, (UINT)GetStockObject(DEFAULT_GUI_FONT), 0L);
MessageBox(NULL, TEXT("the button GRID is clicked."), TEXT("Event"), MB_OK|MB_ICONINFORMATION);
lcWndExeCommand( hLcWnd, LC_CMD_SW_GRID, 0 );
return TRUE;
}
break;
// More cases on WM_NOTIFY switch.
}
break;
//case BN_CLICKED: // Notification message from Button
case NM_CLICK: // Notification message from StatusBar
switch (LOWORD(wParam))
{
case IDC_SNAP: SendMessage(hButton, WM_SETFONT, (UINT)GetStockObject(DEFAULT_GUI_FONT), 0L);
MessageBox(hWnd, TEXT("the button SNAP is clicked."), TEXT("Event"), MB_OK|MB_ICONINFORMATION);
lcWndExeCommand( hLcWnd, LC_CMD_SW_GRIDSNAP, 0 ); break;
case IDC_GRID: SendMessage(hButton, WM_SETFONT, (UINT)GetStockObject(DEFAULT_GUI_FONT), 0L);
lcWndExeCommand( hLcWnd, LC_CMD_SW_GRID, 0 ); break;
case IDC_ORTHO: SendMessage(hButton, WM_SETFONT, (UINT)GetStockObject(DEFAULT_GUI_FONT), 0L);
lcWndExeCommand( hLcWnd, LC_CMD_SW_ORTHO, 0 ); break;
case IDC_POLAR: SendMessage(hButton, WM_SETFONT, (UINT)GetStockObject(DEFAULT_GUI_FONT), 0L);
lcWndExeCommand( hLcWnd, LC_CMD_SW_POLAR, 0 ); break;
case IDC_OSNAP: SendMessage(hButton, WM_SETFONT, (UINT)GetStockObject(DEFAULT_GUI_FONT), 0L);
lcWndExeCommand( hLcWnd, LC_CMD_SW_OSNAP, 0 ); break;
case IDC_LWT: SendMessage(hButton, WM_SETFONT, (UINT)GetStockObject(DEFAULT_GUI_FONT), 0L);
lcWndExeCommand( hLcWnd, LC_CMD_SW_LWEIGHT, 0 ); break;
}
break;
}
return (INT_PTR)FALSE;
}
// end of CALLBACK WndStatusBar()
Buttons and MessageBox "the button SNAP is clicked." not works (!?)