Advertisement

Prob Creating Menus

Started by February 03, 2001 12:07 PM
5 comments, last by doodah2001 23 years, 11 months ago
I''m having a problem creating menus using VC++. I''m not using MFC. I created a script using insert >> resource >> menu. My script is fine and everything. However when I try to create my window with the menu it gives me an error, error C2440: ''='' : cannot convert from ''struct HMENU__ *'' to ''const char *'' Can anybody help me. My code is below. Thanks. #include windows.h #include windowsx.h #include "resource.h" BOOL CreateMyWindow() { WNDCLASSEX wc; wc.cbSize =sizeof(WNDCLASSEX); wc.style =CS_HREDRAW|CS_VREDRAW|CS_OWNDC|CS_DBLCLKS; wc.hInstance =hInstance; wc.cbClsExtra =0; wc.cbWndExtra =0; wc.lpfnWndProc=(WNDPROC)WinProc; wc.hCursor =LoadCursor(NULL, IDC_ARROW); wc.hIcon =LoadIcon(hInstance, IDI_WINLOGO); wc.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH); Error-> wc.lpszMenuName =LoadMenu(hInstance, IDR_MENU1); wc.hIconSm =LoadIcon(hInstance, IDI_WINLOGO); wc.lpszClassName="Game"; yada, yada } WinMain() WinProc()
MatDoodah2001@hotmail.comLife is only as fun as you make it!!!
Hi

you have to convert the menu id with the MAKEINTRESOURCE makro

so the correct codeline would be

wc.lpszMenuName = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1));

Hope that helps





-------------------
MindFly Games
-------------------
Advertisement
I tried it with the MAKEINTRESOURCE(IDR_MENU1) before my first post and that also gave me an error.

error C2440: ''='' : cannot convert from ''struct HMENU__ *'' to ''const char *''
MatDoodah2001@hotmail.comLife is only as fun as you make it!!!
Why not try give the CreateMenu/AppendMenu functions a whirl?

GL!

The nightmare travels across the cosmos with his burning mane. The trail of ash that is produced.

?Have a nice day!?

Considering how I''m new with menu''s, could you please paste just a few snippets of code for the CreateMenu/AppendMenu/InsertMenu functions. Thanks.

Mat
MatDoodah2001@hotmail.comLife is only as fun as you make it!!!
Hi
sorry about that, but i just see you do use LoadMenu only in the CreateWindow func.
To do it your way the code should just be

wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);

i tried it and it works for me, so i hope its right now

-------------------
MindFly Games
-------------------
Advertisement
That did the trick. Thanks!!!
MatDoodah2001@hotmail.comLife is only as fun as you make it!!!

This topic is closed to new replies.

Advertisement