In another thread (http://www.masm32.com/board/index.php?topic=17788.0) here, I asked how to put non-button controls (like comboboxes) in a toolbar, but never really got an answer.
Turns out to be ridiculousy easy; just put the control in the toolbar!
I needed a few comboboxes, so I created them using CreateWindowEx(), making them children of the toolbar. Worked the first time. Easy! I ASS-U-ME the same can be done with other controls (checkboxes, etc.), though I haven't tried it yet.
I still never got an answer to my original question in that thread, which was how to create a strip above a toolbar that could contain other controls. If anyone can tell me how to do this, I'd be much appreciative. I'm talking about a strip immediately below the menu strip of the parent window. Can one create a toolbar with zero buttons? or is there some other clever trick?
By the way, one thing I learned from this is that if you're stuck on a problem, sometimes the best thing to do is to just try something, no matter how far-fetched it might seem at the time. It might just work ...
Quote.ELSEIF uMsg == WM_CREATE
....................................................
invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR CboxClName,
ADDR TextComboBox1,WS_CHILD or WS_BORDER or CBS_HASSTRINGS or \
CBS_DROPDOWNLIST or WS_VSCROLL or WS_VISIBLE,5,5,50,250,hWnd,ComboBox1ID,hInstance,0
mov hwndComboBox,eax ; Combo
lea ebx, ComboString ; заполним Combo контрол
mov ecx, 14
NextNumber:
push ecx
invoke SendDlgItemMessage, hWnd, ComboBox1ID, CB_ADDSTRING, 0, ebx
pop ecx
add ebx, 4
loop NextNumber
invoke SendDlgItemMessage, hWnd, ComboBox1ID, CB_SETCURSEL,ComboNumber,0
Quote
invoke SendDlgItemMessage, hWnd, ComboBox1ID, CB_GETCURSEL,0,0
mov ComboNumber, eax
(http://smiles.kolobok.us/light_skin/bye.gif)
So that's basically what I did, right? Looks like you created a combobox that's a child of another window (can't tell which one, doesn't really matter). I guess everyone else already knew this ...
So do you know how I can get another strip above my toolbar?
WS_CLIPCHILDREN WS_CLIPSIBLINGS You mean something like this? (http://smiles.kolobok.us/light_skin/unknw.gif)
QuoteWS_CLIPSIBLINGS
0x04000000L
Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window.
QuoteWS_CLIPCHILDREN
0x02000000L
Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600%28v=vs.85%29.aspx
What? No. My question is this:
How can i create a strip (child window?) across the top of my application's client area, above an existing toolbar, where I can put other controls?
Could be a rebar, but I'm looking for other solutions. I just want to create a place where I can put miscellaneous controls (checkboxes, edit boxes, etc.), along with possibly some buttons.
CreateToolBarEx(http://s50.radikal.ru/i130/0908/bb/dd7c8a96f9a4.gif)
TBSTYLE_EX_DRAWDDARROWS TBSTYLE_DROPDOWN C sample from russian forum
Quote//----------------------------------------------------------------------------//
#include <windows.h>
#include <commctrl.h>
HWND hEdit, hLabel, hButton, hClrLbl, hBtnFnt,hToolBar, htool2,hcool,
hCombo, hStatus, hList1, hList2, hBtnClr;
HMENU hFileMenu, hHelpMenu, hSubMenu, hMenu, hPopUp;
const IDM_Enable_Disable = 0;
const IDM_Exit = 1;
const IDM_About = 2;
const IDP_File=3;
const IDP_Help = 4;
const IDM_Bitmap =5;
const ToolBtns = 13;
//----------------------------------------------------------------------------//
long __stdcall MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY: { PostQuitMessage( 0 ); return 0;}
case WM_NOTIFY:
{
LPNMTOOLBAR lpnmtb = (LPNMTOOLBAR) lParam;
LPNMHDR lpnm = (LPNMHDR) lParam;
switch (lpnm->code)
{
case TBN_DROPDOWN:
{
switch (lpnmtb->iItem)
{
case 301:
RECT rc;
SendMessage( hToolBar, TB_GETRECT, lpnmtb->iItem, (LPARAM)&rc);
POINT pp;
ZeroMemory( &pp, sizeof(pp));
ClientToScreen( hToolBar, &pp );
TrackPopupMenuEx( hFileMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL,
rc.left+pp.x, rc.bottom+pp.y, hWnd, NULL);
break;
}
}
}
return 0;
}
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
//----------------------------------------------------------------------------//
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
WNDCLASS wc = { CS_HREDRAW | CS_VREDRAW , MsgProc, 0L, 0L, hInstance,
LoadIcon(0, IDI_EXCLAMATION), LoadCursor(0, IDC_ARROW),
(HBRUSH)16, NULL, "Window" };
RegisterClass( &wc );
HWND hWnd = CreateWindow( "Window", "Интерфейс на WinAPI", WS_OVERLAPPEDWINDOW,// |WS_MINIMIZEBOX| WS_SYSMENU,
200, 200, 560, 270, NULL, NULL, wc.hInstance, NULL );
INITCOMMONCONTROLSEX icc={ sizeof(icc), ICC_BAR_CLASSES|ICC_COOL_CLASSES };
InitCommonControlsEx( &icc );
DWORD ws = WS_CHILD | WS_VISIBLE, ws2 = ws | WS_TABSTOP;
TBBUTTON tbb[ToolBtns];
int tbs[ToolBtns]={STD_FILENEW, STD_FILEOPEN, STD_FILESAVE, -1,150,-1, STD_CUT,
STD_COPY, STD_PASTE, -1, STD_UNDO, STD_REDOW, STD_HELP};
ZeroMemory( &tbb, sizeof(tbb));
for(int i=0; i<11; i++)
{
tbb.iBitmap=tbs;
tbb.idCommand=300+i;
tbb.fsState=TBSTATE_ENABLED;
if(tbs==-1) tbb.fsStyle=TBSTYLE_SEP; else
tbb.fsStyle=TBSTYLE_BUTTON ;
tbb.iString=0;
}
tbb[4].fsStyle=TBSTYLE_SEP;
tbb[1].fsStyle=TBSTYLE_DROPDOWN ;
hToolBar = CreateToolbarEx( hWnd, /*CCS_ADJUSTABLE |*/WS_VISIBLE |TBSTYLE_FLAT|TBSTYLE_REGISTERDROP, 299, 15, HINST_COMMCTRL,
IDB_STD_SMALL_COLOR, 0, 0, 16,16, 15,15, sizeof(TBBUTTON) );
DWORD EXST = (DWORD) SendMessage( hToolBar, TB_GETEXTENDEDSTYLE, 0, 0 );
SendMessage( hToolBar, TB_SETEXTENDEDSTYLE, 0, EXST|TBSTYLE_EX_DRAWDDARROWS );
hCombo = CreateWindowEx(WS_EX_CLIENTEDGE , "COMBOBOX", NULL, ws2 |WS_VSCROLL |
CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN ,
90, 0, 150, 150, hToolBar, (HMENU)513, wc.hInstance, NULL); //hCtrls[2] = hCombo;
SetWindowText( hCombo, "<< Выберите пункт >>");
SendMessage( hCombo, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Изменить заголовок" );
SendMessage( hCombo, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Добавить строку" );
SendMessage( hCombo, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Выход из программы" );
SendMessage( hCombo, CB_SETDROPPEDWIDTH, 200, 0 );
AppendMenu((hSubMenu=CreatePopupMenu()), MF_GRAYED | MF_STRING, 100,"Submenu 1 >");
AppendMenu( hSubMenu, MF_ENABLED | MF_STRING, 100,"Submenu 2");
AppendMenu((hFileMenu=CreatePopupMenu()), MF_ENABLED | MF_STRING, IDM_Enable_Disable, "&Enable exit");
AppendMenu( hFileMenu, MF_SEPARATOR, 0,"");
AppendMenu( hFileMenu, MF_ENABLED | MF_STRING | MF_POPUP,(UINT) hSubMenu,"&Right ->");
AppendMenu( hFileMenu, MF_GRAYED | MF_STRING, (IDM_Exit+200),"E&xit");
SendMessage( hToolBar, TB_ADDBUTTONS, (UINT)11, (LPARAM)(LPTBBUTTON) &tbb );
{
ShowWindow ( hWnd, SW_SHOWDEFAULT ), UpdateWindow( hWnd );
MSG msg;
while( GetMessage( &msg, NULL, 0, 0 ) )
if(!IsDialogMessage( hWnd, &msg ))
TranslateMessage( &msg ),
DispatchMessage ( &msg );
}
UnregisterClass( "Window", wc.hInstance );
}
//----------------------------------------------------------------------------//