Click here to Skip to main content
15,922,894 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Answer[Message Deleted] Pin
User 21559720-Aug-08 23:22
User 21559720-Aug-08 23:22 
QuestionRe: Automatic installation procedure question Pin
Rajesh R Subramanian20-Aug-08 23:24
professionalRajesh R Subramanian20-Aug-08 23:24 
Answer[Message Deleted] Pin
User 21559721-Aug-08 0:04
User 21559721-Aug-08 0:04 
GeneralRe: Automatic installation procedure question Pin
Rajesh R Subramanian21-Aug-08 0:36
professionalRajesh R Subramanian21-Aug-08 0:36 
GeneralRe: Automatic installation procedure question Pin
User 21559721-Aug-08 0:52
User 21559721-Aug-08 0:52 
GeneralRe: Automatic installation procedure question Pin
Rajesh R Subramanian21-Aug-08 0:57
professionalRajesh R Subramanian21-Aug-08 0:57 
GeneralRe: Automatic installation procedure question Pin
User 21559721-Aug-08 1:35
User 21559721-Aug-08 1:35 
QuestionThe code fails to display the image (win32 sdk c++ programming) Pin
raesa20-Aug-08 20:53
raesa20-Aug-08 20:53 
Hi, i have written a small code to load a bitmap and display it on the window. The bitmap doesnt get displayed and i get only a blank window.I dont understand where the problem is.Please look at my code and do let me know if i am going wrong somewhere.Plse do help me out.Thnx in advance.

my code:
/*************************************************/
#include "windows.h"
#include "resource.h"
#include "iostream"
#include "tchar.h"

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
typedef std::basic_string<TCHAR> ustring;

HBITMAP hBmp;

int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
LPSTR lpszArgument,int nFunsterStil)
{

HINSTANCE hInst = NULL;
ustring uClassName=_T("SIMPLEWND");

WNDCLASSEX wMyClass={0};
wMyClass.cbSize = sizeof(WNDCLASSEX);
wMyClass.lpfnWndProc = WndProc;
wMyClass.hInstance = hInst;
wMyClass.hIcon = (HICON)(LoadImage(0,IDI_APPLICATION, IMAGE_ICON,0,0,LR_SHARED));
wMyClass.hCursor = (HCURSOR)(LoadImage(0,IDC_ARROW,IMAGE_CURSOR,0,0,LR_SHARED));
wMyClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wMyClass.lpszClassName = uClassName.c_str();
if (!RegisterClassEx(&wMyClass))
{
MessageBox(NULL, "Failed to register wnd class", "Information", MB_OK);
return -1;
}

int desktopwidth=GetSystemMetrics(SM_CXSCREEN);
int desktopheight=GetSystemMetrics(SM_CYSCREEN);

HWND hwnd=CreateWindowEx(0,uClassName.c_str(),_T("Simple Window"),WS_OVERLAPPEDWINDOW,
desktopwidth/4,desktopheight/6,desktopwidth/2,desktopheight/2, 0, 0,
hInst, 0);
if (!hwnd)
{
MessageBox(NULL, "Failed to create wnd", "Information", MB_OK);
return -1;
}

ShowWindow(hwnd, 1);
UpdateWindow(hwnd);

hBmp =LoadBitmap(wMyClass.hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
if( hBmp == NULL)
{
MessageBox(NULL, "Failed to load bmp", "Information", MB_OK);
UnregisterClass(uClassName.c_str(), hInst);
return -1;
}

UpdateWindow(hwnd);

MSG msg;
while (GetMessage(&msg,0,0,0)>0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

UnregisterClass(uClassName.c_str(), hInst);
}
int PaintFunc( HWND hwnd )
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd,&ps);
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmp =(HBITMAP) GetProp(hwnd,"hbmp");
if(hbmp) {
BITMAP bm;
GetObject(hbmp,sizeof(bm),(LPSTR)&bm);
hbmp = (HBITMAP)SelectObject(hdcMem,hbmp);
BitBlt(hdc,0,0,bm.bmWidth,bm.bmHeight,hdcMem,0,0,SRCCOPY);
hbmp = (HBITMAP)SelectObject(hdcMem,hbmp);
}
DeleteDC(hdcMem);
EndPaint(hwnd,&ps);
return 0;
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
PaintFunc(hWnd);
return 0;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);

}
}
/*************************************************/
AnswerRe: The code fails to display the image (win32 sdk c++ programming) Pin
567890123420-Aug-08 21:06
567890123420-Aug-08 21:06 
GeneralRe: The code fails to display the image (win32 sdk c++ programming) Pin
raesa20-Aug-08 21:11
raesa20-Aug-08 21:11 
AnswerRe: The code fails to display the image (win32 sdk c++ programming) Pin
Naveen20-Aug-08 21:12
Naveen20-Aug-08 21:12 
GeneralRe: The code fails to display the image (win32 sdk c++ programming) Pin
raesa20-Aug-08 22:14
raesa20-Aug-08 22:14 
QuestionCopy USB Device Data To System Pin
NewVC++20-Aug-08 20:47
NewVC++20-Aug-08 20:47 
AnswerRe: Copy USB Device Data To System Pin
Cedric Moonen20-Aug-08 21:14
Cedric Moonen20-Aug-08 21:14 
GeneralRe: Copy USB Device Data To System Pin
NewVC++20-Aug-08 21:35
NewVC++20-Aug-08 21:35 
GeneralRe: Copy USB Device Data To System Pin
Cedric Moonen20-Aug-08 21:54
Cedric Moonen20-Aug-08 21:54 
GeneralRe: Copy USB Device Data To System Pin
NewVC++20-Aug-08 22:05
NewVC++20-Aug-08 22:05 
GeneralRe: Copy USB Device Data To System Pin
Cedric Moonen20-Aug-08 22:11
Cedric Moonen20-Aug-08 22:11 
GeneralRe: Copy USB Device Data To System Pin
NewVC++20-Aug-08 22:21
NewVC++20-Aug-08 22:21 
GeneralRe: Copy USB Device Data To System Pin
Cedric Moonen20-Aug-08 22:27
Cedric Moonen20-Aug-08 22:27 
GeneralRe: Copy USB Device Data To System Pin
SandipG 20-Aug-08 22:23
SandipG 20-Aug-08 22:23 
AnswerRe: Copy USB Device Data To System Pin
User 21559720-Aug-08 23:01
User 21559720-Aug-08 23:01 
QuestionDummy Line Pin
NewVC++20-Aug-08 20:31
NewVC++20-Aug-08 20:31 
QuestionRepost. Pin
CPallini20-Aug-08 22:08
mveCPallini20-Aug-08 22:08 
AnswerRe: Repost. Pin
NewVC++20-Aug-08 22:28
NewVC++20-Aug-08 22:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.