I've got a question about this part:
case WM_CREATE:
HANDLE imgloader;
imgloader = LoadImage((HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), "launch.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
if(imgloader == NULL)
MessageBox(hwnd, "Could not load ModXP Box Image!", "Error", MB_OK | MB_ICONEXCLAMATION);
break;
That's what i use to load a bitmap called "launch.bmp" and when i compile it works, becuz it doesn't come up with the messagebox.(so i can say it loaded, or st is going totally wrong ;) ) But now i haven't got a clue how to get this bitmap to display in my window/app. Any suggestions? (i know i need to use WM_PAINT, but what do i put in there?)
Thanks in advance,
Tim 2K
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes. I usually use a second one to allow additional processing such as a caption and what not to be overlayed. Force of habbit =)
Kip
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-12-18
Ok thanks guys! :D (i'm the nobody poster btw ;) )
Going to try it out rite now
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-12-18
Hmmzzz, i'm new to this stuff.. I'm not in a dialog.. Should i be in a dialog to do this? (I'm also searching for the dialog inserted but i can't find it in the 4.9.8 version in the latest final version (4 or whateva) it was in the insert thingie.
Tim 2K
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Because a bitmpa is a default windows image it has it own API LoadBitmap(HINSTANCE hInstance, LPCTSTR lpBitmapName);
to get fomr a resource file use
HBITMAP Bitmpa;
BitMap = LoadBitmap(hInst,MAKEINTRESOURCE ( /* either(LPCSTR) "BITMAP") or "BITMAP" */ (LPCSTR)"SOMEBITMAP") );
then selct Get and bitblt to the screen.
Dark Omen
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-12-19
Ok could somebody plz create .dev and .ccp files for me? With comments if that's doable. Thanks in advance, (this is driving me crazy :S )
Tim 2K
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
/* Make the class name into a global variable */
char szClassName[ ] = "DreamXPApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil) {
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_WINDOW;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"DreamXP", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0)) {
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
EndPaint(hwnd, &ps);
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
break;
}
return 0;
}
***
Images.rc->
***
LAUNCH BITMAP "launch.bmp"
***
This loop gets run:
if(!hLaunch){
PostQuitMessage(0);
}
And I don't get why, cause it should load the resources properly.
Help! Thanks in advance,
(btw, sorry for the big post, i couldn't find an attach file button :S )
Tim 2K
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-12-21
Anybody?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-12-22
Hmmzzz, could somebody please help, i really need this to work. Otherwise i'll go work on my website and i'll check l8r this week. Thanks in advance,
Tim 2K
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
//hLaunch = LoadBitmap(g_hInst, "LAUNCH");
// We need to use a handle to the *file* ("module")
// with the bmp in it! (That would be this exe.)
hLaunch = LoadBitmap(GetModuleHandle(NULL), "LAUNCH");
-- Jim.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Howdy!
I've got a question about this part:
case WM_CREATE:
HANDLE imgloader;
imgloader = LoadImage((HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), "launch.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
if(imgloader == NULL)
MessageBox(hwnd, "Could not load ModXP Box Image!", "Error", MB_OK | MB_ICONEXCLAMATION);
break;
That's what i use to load a bitmap called "launch.bmp" and when i compile it works, becuz it doesn't come up with the messagebox.(so i can say it loaded, or st is going totally wrong ;) ) But now i haven't got a clue how to get this bitmap to display in my window/app. Any suggestions? (i know i need to use WM_PAINT, but what do i put in there?)
Thanks in advance,
Tim 2K
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Resources/IntroductiontoResources/ResourceReference/ResourceFunctions/LoadImage.asp
// Load image...
hLoader = LoadImage()
// Repaint time...
case WM_PAINT:
// Begin painting...
hDC = BeginPaint(hDialog, &ps);
// Paint loader bitmap...
// Initialize bitmap...
hDCLoaderBitmap = CreateCompatibleDC(0);
SelectObject(hDCLoaderBitmap, hLoader);
// Blit splash bitmap onto dialog using correct coordinates...
GetObject(hLoader, sizeof(BITMAP), &Bitmap);
BitBlt(hDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight,
hDCLoaderBitmap, 0,0, SRCCOPY);
// Cleanup...
DeleteObject(hDCLoaderBitmap);
break;
Do not forget the DeleteObject() or your app will suffer from severe memory leak. Enjoy =)
Kip
after using the LoadImage function, you then use the SelectObject API to select the image into the DC specified
Yes. I usually use a second one to allow additional processing such as a caption and what not to be overlayed. Force of habbit =)
Kip
Ok thanks guys! :D (i'm the nobody poster btw ;) )
Going to try it out rite now
Hmmzzz, i'm new to this stuff.. I'm not in a dialog.. Should i be in a dialog to do this? (I'm also searching for the dialog inserted but i can't find it in the 4.9.8 version in the latest final version (4 or whateva) it was in the insert thingie.
Tim 2K
If you use a dialog, remember to change WM_CREATE to WM_INITDIALOG. Enjoy =)
Kip
Because a bitmpa is a default windows image it has it own API LoadBitmap(HINSTANCE hInstance, LPCTSTR lpBitmapName);
to get fomr a resource file use
HBITMAP Bitmpa;
BitMap = LoadBitmap(hInst,MAKEINTRESOURCE ( /* either(LPCSTR) "BITMAP") or "BITMAP" */ (LPCSTR)"SOMEBITMAP") );
then selct Get and bitblt to the screen.
Dark Omen
Ok could somebody plz create .dev and .ccp files for me? With comments if that's doable. Thanks in advance, (this is driving me crazy :S )
Tim 2K
look in your example directory under win32 anim it show you how to load and show the bmp etc.
Right! I did that.. But didn't work as planned :P
Project: DreamXP
Files: main.ccp (main file)
Images.rc (resource file in folder Resources)
main.ccp ->
***
#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
static HINSTANCE g_hInst = NULL;
HBITMAP hLaunch;
BITMAP bm;
/* Make the class name into a global variable */
char szClassName[ ] = "DreamXPApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil) {
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_WINDOW;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"DreamXP", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0)) {
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) { /* handle the messages */
case WM_CREATE:
hLaunch = LoadBitmap(g_hInst, "LAUNCH");
if(!hLaunch){
PostQuitMessage(0);
}
GetObject(hLaunch, sizeof(bm), &bm);
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
case WM_PAINT:
HDC hdc;
hdc = GetDC(hwnd);
PAINTSTRUCT ps;
HDC hdcWindow;
hdcWindow = BeginPaint(hwnd, &ps);
HDC hdcMemory;
hdcMemory = CreateCompatibleDC(hdc);
/*SelectObject(hdcMemory, hbmMask);
BitBlt(hdc, ballX, ballY, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCAND);*/
SelectObject(hdcMemory, hLaunch);
BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCPAINT);
DeleteDC(hdcMemory);
EndPaint(hwnd, &ps);
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
break;
}
return 0;
}
***
Images.rc->
***
LAUNCH BITMAP "launch.bmp"
***
This loop gets run:
if(!hLaunch){
PostQuitMessage(0);
}
And I don't get why, cause it should load the resources properly.
Help! Thanks in advance,
(btw, sorry for the big post, i couldn't find an attach file button :S )
Tim 2K
Anybody?
Hmmzzz, could somebody please help, i really need this to work. Otherwise i'll go work on my website and i'll check l8r this week. Thanks in advance,
Tim 2K
You try to load the bitmap with :
hLaunch = LoadBitmap(g_hInst, "LAUNCH");
but g_hInst is NULL because you wrote
static HINSTANCE g_hInst = NULL;
You should add
g_hInst=hThisInstance;
in WinMain, somewhere before CreateWindowEx.
I noticed something else about your code which has nothing to do with your question.
If you really want to "Use Windows's default color as the background of the window", you should write
wincl.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
Liviu
Take a look at the change below. It works here.
//hLaunch = LoadBitmap(g_hInst, "LAUNCH");
// We need to use a handle to the *file* ("module")
// with the bmp in it! (That would be this exe.)
hLaunch = LoadBitmap(GetModuleHandle(NULL), "LAUNCH");
-- Jim.