Creating a toolbar using CreateWindowEX()
Im trying to create a tool bar for a text editor using CreateWindowEX().
The tool bar will show up fine, but then when you click on the button nothing will happen. Also, when you start typing in the edit box it just types over the tool bar and it eventually disapears.
I have included commctrl.h and linked comctl32.lib.
I have also called InitCommonControls();
heres the code that i used to create the tool bar
This function is called in WinMain after the creation of my window and the hwnd for my window is used as the parameter.
void Document::CreateToolBar(const HWND &hwnd)
TBBUTTON tbbutton;//struct for buttons
TBADDBITMAP tbbit;//struct for bitmaps on the buttons
htool=CreateWindowEx(0, TOOLBARCLASSNAME,/*constant in commctrl.h*/ NULL, WS_CHILD | WS_VISIBLE, 0,0,0,0,
hwnd/*handle to the window i want it in*/,NULL, GetModuleHandle(NULL), NULL);
//send TB_BUTTONSTRUCTSIZE msg for backwards compatibility
SendMessage(htool,TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
//add standard bitmaps
tbbit.hInst= HINST_COMMCTRL; //defined in header file
tbbit.nID = IDB_STD_SMALL_COLOR;
SendMessage(htool,TB_ADDBITMAP, 0, (LPARAM)&tbbit);
tbbutton.iBitmap = STD_FILEOPEN;
tbbutton.fsState = TBSTATE_ENABLED;
tbbutton.fsStyle = TBSTYLE_BUTTON;
tbbutton.idCommand = M_OPEN;
SendMessage(htool,TB_ADDBUTTONS, sizeof(tbbutton)/sizeof(TBBUTTON), (LPARAM) &tbbutton);
//above tells how many buttons we have
}//end of Document::CreateToolBar()
I think that it might be relevant to put in the code that I used to create the edit box also:
Any help is appreciated.
void Document::CreateEditBox(const HWND &hwnd, const LPARAM &lparam, HWND &edit,const RECT &rect)
//create the edit box
//"EDIT" = a predefined window
//WS_CHILD = child to window, uses same WndProc
//ES_NOHIDEESEL = won't hid it when its not in focus
//ES_WANTRETURN = <enter>will be a carriage return
//((LPCREATESTRUCT)lparam)->hInstance = digs up the hinstance
edit=CreateWindow("EDIT",NULL,WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL |
ES_AUTOVSCROLL | ES_LEFT | ES_MULTILINE |
ES_NOHIDESEL | WS_VSCROLL | WS_HSCROLL |
WS_BORDER | ES_WANTRETURN,
0, 0, rect.right, rect.bottom, hwnd, (HMENU)EDIT_BOX,
}//end of CreateEditBox()
Thank you in advance.