Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MENTAL

Newbie Question

This topic is 6922 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Seeing as questions with that yype of subject get a good responce, I''m gonna try it out and see. After a total of NULL replies to my last post, I''m going to repeat myself. I''ve created a toolbar resource in Visual C++ 6. Now, how the hell do I get it to display on the window? I''m not using MFC (uuugghhh), so I''m a bit stuck at the moment. If anyone could help i would love you for life (in a plutonic sence) MENTAL

Share this post


Link to post
Share on other sites
Advertisement
No need to use "off-the-subject-titles"!
The right people are not always present:-)

But let''s get down to the subject. Here''s some old code (I dont know if it works) but it should...


InitCommonControls();

const TBBUTTON Buttons[] =
{ { -1, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, -1 },
{ 0, ID_SELECT, TBSTATE_ENABLED/TBSTATE_CHECKED, TBSTYLE_CHECK/TBSTYLE_GROUP, 0, 0 },
{ 1, ID_MOVETO, TBSTATE_ENABLED, TBSTYLE_CHECK/TBSTYLE_GROUP, 0, 1 },
{ -1, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, -1 },
{ 2, ID_LEFT, TBSTATE_ENABLED, TBSTYLE_BUTTON/TBSTYLE_GROUP, 0, 2 },
{ 3, ID_RIGHT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 3 },
{ 4, ID_UP, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 4 },
{ 5, ID_DOWN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 5 },
};

HINSTANCE hInst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);

return CreateToolbarEx(
hWndParent,
WS_CHILD/WS_VISIBLE,
IDR_TOOLBAR,
9,
hInst,
IDR_TOOLBAR,
Buttons,
sizeof(Buttons)/sizeof(TBBUTTON),
24,
22,
16,
15,
sizeof(TBBUTTON));


Don''t forget to #include at the top and link with...eh...was it comctl32.lib?

Hope it helps,
Bas.


P.S.: I''m no fan of MFC either. But gives you draggable toolbars, nice statusbar and MDI stuff with a few clicks.
Sime time ago I coded a draggable toolwindow myself...before I found out MFC is ...uhum "faster". Whoow what a compliment, never thought I''d say anything like that??!?

Share this post


Link to post
Share on other sites
Thanks for the help, but the toolbar still wont display on the window. It compiles ok (only after I remembered to add the "commctrl.h" file ), but the damn thing still wont show.

I''m currently putting the code in the InitInstance function. Is this correct, or have I got it in the wrong place.


BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) {
HWND hWnd;

hInst = hInstance; // Store instance handle in our global variable

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

if (!hWnd) {
return FALSE;
}

InitCommonControls();

const TBBUTTON Buttons[] = {
{ -1, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, -1 },
{ 0, ID_SELECT, TBSTATE_ENABLED/TBSTATE_CHECKED, TBSTYLE_CHECK/TBSTYLE_GROUP, 0, 0 },
{ 1, ID_MOVETO, TBSTATE_ENABLED, TBSTYLE_CHECK/TBSTYLE_GROUP, 0, 1 },
{ -1, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, -1 },
{ 2, ID_LEFT, TBSTATE_ENABLED, TBSTYLE_BUTTON/TBSTYLE_GROUP, 0, 2 },
{ 3, ID_RIGHT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 3 },
{ 4, ID_UP, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 4 },
{ 5, ID_DOWN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 5 },
};

hInst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);

if(!CreateToolbarEx(
hWnd,
WS_CHILD/WS_VISIBLE,
IDR_TOOLBAR1,
9,
hInst,
IDR_TOOLBAR1,
Buttons,
sizeof(Buttons)/sizeof(TBBUTTON),
24,
22,
16,
15,
sizeof(TBBUTTON)))
return FALSE;

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);

return TRUE;
}


Please help

MENTAL

Share this post


Link to post
Share on other sites
Uhm ....
You should first save the handle returned by CreateToolbarEx and add this code before returning from the InitInstance function :

// Send the TB_BUTTONSTRUCTSIZE message, which is required
// for backward compatibility.
SendMessage(hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
SendMessage(hwndTB, TB_ADDBUTTONS, (WPARAM) ,
(LPARAM) (LPTBBUTTON) &Buttons);
SendMessage(hwndTB, TB_AUTOSIZE, 0, 0);
ShowWindow(hwndTB, SW_SHOW);

The TB_ADDBUTTONS adds the buttons to the toolbar according to the buttons information.

Share this post


Link to post
Share on other sites
eww... i have some clean code (hehe, ) at home that will do the job, and it isn''t MFC. I''ll post again later .

-----------------------------------------------------------
PCMCIA - People Can't Memorize Computer Industry Acronyms
ISDN - It Still Does Nothing
APPLE - Arrogance Produces Profit-Losing Entity
SCSI - System Can't See It
DOS - Defunct Operating System
BASIC - Bill's Attempt to Seize Industry Control
IBM - I Blame Microsoft
DEC - Do Expect Cuts
CD-ROM - Consumer Device, Rendered Obsolete in Months
OS/2 - Obsolete Soon, Too.
WWW - World Wide Wait
MACINTOSH - Most Applications Crash; If Not, The Operating System Hangs

Share this post


Link to post
Share on other sites
Thank you very much all, I''m useless when it comes to win32 GDI programming - opengl is far more interesting. The reason I need this code is for some development tools i''m creating to ease the pain a little .

Zipster: I look forward to seeing your code .

MENTAL

Windows: Will install needless data on whole system
Microsoft: Most intelligent customers realise our software only feels tested.

hehe

"Who needs more than 640kb of memory?" - Bill Gates ''89

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!