Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 9th, 2005, 2:06 AM   #1
hemanth.balaji
Programmer
 
Join Date: May 2005
Posts: 54
Rep Power: 0 hemanth.balaji is an unknown quantity at this point
Send a message via Yahoo to hemanth.balaji Send a message via Skype™ to hemanth.balaji
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
hemanth.balaji is offline   Reply With Quote
Old Jun 9th, 2005, 4:42 AM   #2
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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
nnxion is offline   Reply With Quote
Old Jun 9th, 2005, 5:47 AM   #3
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
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
Berto is offline   Reply With Quote
Old Jun 9th, 2005, 8:04 AM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:16 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC