|
I found a very useful guide to Windows programming from the ground up here. I followed it pretty closely, changing around a little bit by functionizing the initialization. The problem is when I run my app, it consumes all CPU power but I don't have it doing anything when the window pops up, just a window with a menu on top. Can someone go through that page and tell me if I or he missed something to create this problem? Thanks in advance.
|
|
|
|
|
Without seeing what code you actually put in place, it's kind of hard to say what might be wrong.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I tried to not put code on here because of it's size, but if it must be done. Here's all I wrote, it creates a simple white window.
#define WIN32_LEAN_AND_MEAN<br />
<br />
#include <windows.h><br />
#include <windowsx.h><br />
<br />
LRESULT CALLBACK MessageHandler (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {<br />
return DefWindowProc (hWnd, Msg, wParam, lParam);<br />
}<br />
<br />
ATOM InitializeWindowClass (HINSTANCE hInstance) {<br />
WNDCLASSEX wndClass;<br />
<br />
wndClass.cbSize = sizeof(WNDCLASSEX);<br />
wndClass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;<br />
wndClass.lpfnWndProc = MessageHandler;<br />
wndClass.cbClsExtra = 0;<br />
wndClass.cbWndExtra = 0;<br />
wndClass.hInstance = hInstance;<br />
wndClass.hIcon = LoadIcon (NULL, IDI_WINLOGO);<br />
wndClass.hCursor = LoadCursor (NULL, IDC_ARROW);<br />
wndClass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);<br />
wndClass.lpszMenuName = NULL;<br />
wndClass.lpszClassName = "Win32 Test";<br />
wndClass.hIconSm = LoadIcon (NULL, IDI_WINLOGO);<br />
<br />
return RegisterClassEx(&wndClass);<br />
}<br />
<br />
HWND CreateRootWindow (HINSTANCE hInstance) {<br />
HWND hWnd = CreateWindowEx(NULL, <br />
"Win32 Test",<br />
"Sample Window",<br />
WS_POPUP | WS_VISIBLE,<br />
300, 300, 800, 600,<br />
NULL,<br />
NULL,<br />
hInstance,<br />
NULL);<br />
<br />
return hWnd;<br />
}<br />
<br />
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {<br />
LPMSG msg = NULL;<br />
<br />
InitializeWindowClass (hInstance);<br />
HWND hWnd = CreateRootWindow (hInstance);<br />
<br />
while (true) {<br />
if (PeekMessage(msg, NULL, 0, 0, PM_REMOVE)) {<br />
TranslateMessage(msg);<br />
DispatchMessage(msg);<br />
}<br />
<br />
}<br />
|
|
|
|
|
maybe you sould take a look at WaitMessage(VOID);
|
|
|
|
|
I had a suspicion something like that was there but I just couldn't find it. Thanks. Now to try to figure out the menus.
|
|
|
|
|
Try replacing:
<br />
while( true )<br />
{<br />
if( PeekMessage(...) )<br />
with
<br />
while( GetMessage(...) )<br />
GetMessage stops the program for running while waiting for a message, while PeekMessage doesn't, and you have a loop running at full speed.
HTH
|
|
|
|
|
Good call, I was wary of the `while(true)' loop.
|
|
|
|
|
Shouldn't that message loop be:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(msg);
DispatchMessage(msg);
}
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Yes, as long as this window message handling loop is not responsible for any dialog boxes.
Otherwise, and you need to know the dialog box's window handle:
while (GetMessage(&msg, NULL, 0, 0)){
if( !IsDialogMessage(hWndDialogBox, &msg) ){
TranslateMessage(&msg);
DispatchMessage (&msg);
}
}
You also might want to break if the message is WM_QUIT.
Now, the new and improved suggestions, from MSDN is:
BOOL bRet;
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
if( !IsDialogMessage(hWndDialogBox, &msg) ){
TranslateMessage(&msg);
DispatchMessage (&msg);
}
}
}
|
|
|
|
|
Hi all,
I was wondering if anyone could refer me to some c++ class that can be used to generate xml code from a dtd file. If not, then if someone knows of a class that can be used to validate a dtd file and/or tokenize it; not validate xml using dtd, but make sure that a dtd file is "valid".
Thanks in advance,
-----------------
Genaro
\\\|
_ _
@ @
_\\
--|
_/
|
|
|
|
|
I'm not sure, but I'd lean towards the IXMLDOMDocument interface and its methods.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I looked into this class, but I am pretty sure it doesn't provide this functionality. I have not been able to find any class that will generate a basic valid xml document from a dtd file.
-----------------
Genaro
\\\|
_ _
@ @
_\\
--|
_/
|
|
|
|
|
HI
I am getting error in executing a program ..It says that a dll file is not found.
How do I fix that?
Thanks
Preeti9
|
|
|
|
|
Preeti9 wrote:
How do I fix that?
Supply the missing DLL, perhaps, or at least ensure that the DLL is located in one of the paths pointed to by the PATH environment variable. Without any more detailed information than what you've provided, I can't offer much more.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Thanks for reply
I don't understand how to ask...But let's see....
I don't know how to add that DLL file. I don't know why it is looking for that DLL file.
What do you mean when it says that
"Installing the file can fix the problem" ?
Thanks
Preeti9
|
|
|
|
|
Preeti9 wrote:
I don't know why it is looking for that DLL file.
Use Dependency Walker or Dumpbin to find out what DLLs are required by the application. Those DLLs, and possibly others, must exist on the target machine.
Preeti9 wrote:
What do you mean when it says that
"Installing the file can fix the problem" ?
Isn't that self-explanatory? If the file existed and could be located by the OS, the problem would not exist.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I know that's self explanatory but I didn't know where from install the DLL file.
Thanks
Preeti9
|
|
|
|
|
Preeti9 wrote:
...but I didn't know where from install the DLL file.
And you assumed someone here would, given that you did not provide the name of the application or the missing DLL?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
The missing DLL is MSNHook.DLL
Tell me where to find this?
Thanks
Preeti9
|
|
|
|
|
Preeti9 wrote:
The missing DLL is MSNHook.DLL
I believe, First you have to build the dll project come with you sample application.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Yes,
Thanks a lot...I am trying it that way now...
Preeti9
|
|
|
|
|
I'm having trouble when I export an image as a bitmap on a 16-bit color system (seems to work well under 24 or 32 bit color). The strange thing is that when I bitblt the image to the screen, it looks right but when I save it to a file, the colors are completely off (I mean completely) though the image is not distorted in any other way. I'm pretty sure this has to do with my lack of understanding of bitmaps and 16 vs 32 bit color.
How is each pixel represented. I'm guessing it must be an index, not an actual color value since there are only 2 bytes available. Here's how I build the bitmap header structure:
<br />
BITMAP bm; <br />
bitmap->GetBitmap(&bm);<br />
bm.bmBits = new RGBQUAD[640*480];<br />
bitmap->GetBitmapBits (sizeof(RGBQUAD)*(640*480), bm.bmBits);<br />
<br />
BITMAPINFO BitInfo;<br />
ZeroMemory(&BitInfo, sizeof(BITMAPINFO));<br />
BitInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); <br />
BitInfo.bmiHeader.biBitCount = bm.bmBitsPixel;<br />
BitInfo.bmiHeader.biHeight = -bm.bmHeight;<br />
BitInfo.bmiHeader.biWidth = bm.bmWidth;<br />
BitInfo.bmiHeader.biPlanes = bm.bmPlanes;<br />
BitInfo.bmiHeader.biSizeImage = 0;<br />
BitInfo.bmiHeader.biCompression = BI_RGB;<br />
<br />
BITMAPFILEHEADER BmHdr; <br />
BmHdr.bfType = 0x4d42;
BmHdr.bfSize = (((3 * bm.bmWidth + 3) & ~3) * bm.bmHeight) + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);<br />
<br />
BmHdr.bfReserved1 = BmHdr.bfReserved2 = 0;<br />
BmHdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); <br />
BitInfo.bmiHeader.biCompression = 0;<br />
Does anyone have any ideas?
Karim Shehade
http://www.iwonderdesigns.com
|
|
|
|
|
Karim Shehadeh wrote:
How is each pixel represented
2 bytes per pixel: _rrrrrgggggbbbbb (5-5-5) or rrrrrggggggbbbbb (5-6-5)
no palette.
how are you viewing the BMPs ?
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Chris Losinger wrote:
how are you viewing the BMPs ?
I'm viewing the bitmaps via a photoshop and the built in preview app in WinXP.
Karim Shehade
http://www.iwonderdesigns.com
|
|
|
|
|
the only thing that looks even a little off is the bmSize calculation, because that looks like it assumes 32 bit pixels. but that shouldn't affect the colors - most programs don't care about that value.
what does your BITMAPINFOHEADER struct look like after you've filled it in ?
-c
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|