![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
|
Bitmap Display Probelm
I have to build a project. For that I am using an
OWNER Drwan Menu. Now i want the small part of the remaining space to have an image. i.e a small logo in the top right corner of the application on the menu bar unused space. Now to dry that I just typed a code to display an image somewahere in the main window. But the output is not showing the Bitmap. Why is that. What is the probelm with the below code #include <windows.h> #include"resource.h" #define ID_FILE_EXIT 9001 #define ID_STUFF_GO 9002 const char g_szClassName[] = "myWindowClass"; HINSTANCE hInstance; LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { HDC hDC, MemDCExercising; PAINTSTRUCT Ps; HBITMAP bmpExercising; switch(Message) { case WM_CREATE: { HMENU hMenu, hSubMenu; hMenu = CreateMenu(); hSubMenu = CreatePopupMenu(); AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "E&xit"); AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&File"); hSubMenu = CreatePopupMenu(); AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Go"); AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Stuff"); SetMenu(hwnd, hMenu); } break; case WM_PAINT: { hDC = BeginPaint(hwnd, &Ps); // Load the bitmap from the resource bmpExercising = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_EXERCISING)); // Create a memory device compatible with the above DC variable MemDCExercising = CreateCompatibleDC(hDC); // Select the new bitmap SelectObject(MemDCExercising, bmpExercising); // Copy the bits from the memory DC into the current dc BitBlt(hDC, 200, 200, 200, 200, MemDCExercising, 0, 0, SRCCOPY); // Restore the old bitmap DeleteDC(MemDCExercising); DeleteObject(bmpExercising); EndPaint(hwnd, &Ps); } break; case WM_COMMAND: switch(LOWORD(wParam)) { case ID_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); break; case ID_STUFF_GO: break; } break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, Message, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = NULL; RegisterClassEx(&wc); hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "A Menu ", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, hInstance, NULL); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } I have also uploaded the project itself : http://www.geocities.com/kalamirch/menu_two.zip |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Ya might want to edit your post and put it in [code] tags
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#3 |
|
Programming Guru
![]() |
yes i agree if it was small then i would not mind but its a lot of code and since its not tabbed i aint gonna read it.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity." - Albert Einstein |
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Leastways th' braces are all up agin the left margin, where you can find one when ya need it.
![]()
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|