|
You should load your bitmap into a compatible device context and then use the BitBlt() function to copy to the screen. Here[^] is a useful tutorial on using bitmaps, and here[^] is a link to the MSDN documentation.
|
|
|
|
|
|
hi you. thanks for your help.this is functions i used:
sOldBltMode = SetStretchBltMode( hDC, STRETCH_DELETESCANS );
// Create the palette.
hPal = CreateDibPalette();
if ( hPal )
{
hOldPal = SelectPalette( hDC, hPal, FALSE );
if ( hOldPal ) RealizePalette(hDC);
}
StretchDibBlt( hDC, r.left, r.top, r.Width(), r.Height(),
hMem,
Source.left, Source.top, Source.Width(), Source.Height(),
SRCCOPY );
if ( hPal && hOldPal ) SelectPalette( hDC, hOldPal, FALSE );
if ( hPal ) DeleteObject( hPal );
// Reset the stretch mode.
SetStretchBltMode( hDC, sOldBltMode );
===> first.I show image 10x10inch from file image bitmap. after,i double lick into it, and i will show properties. i choice size 1x1inch. size 10x10inch not yet clear. have i must clear image 10x10inch ? wish your help
nothing
|
|
|
|
|
Hi all,
I am using ListBox control to display the items.
i want to disable keybord events for this ListBox.
Using mouse click if we select items no problem is coming.
If I use arrow key then the selection of items are not coming in order.
I want to stop the keyboad events to this Listbox control
|
|
|
|
|
I do not know your requirements but disabling keyboard events to force the user to use the mouse doesn't sound too nice to me, maybe you should either rethink the way you handle the selection changes or maybe post a question about the root of the problem, someone might be able to help. Anyways, subclass the listbox and try to give handlers to WM_KEYDOWN, WM_KEYUP and WM_CHAR and don't call the super handlers for these. You might need to experiment around to find out what combination of these has to be owerwritten and what else you need to handle to get what you want. I hope this will work for you, good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Hi,
Thank you.
I have developed with my own CListBox class
overwritten OnKeyDown() handler. By doing this it is working.
Regards,
Sakhalean
|
|
|
|
|
I'm creating a window using the following:
WNDCLASSEX wndClass;
wndClass.cbClsExtra = NULL;
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.cbWndExtra = NULL;
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hInstance = mHInst;
wndClass.lpfnWndProc = &Window::msgRouter;
wndClass.lpszClassName = mWindowClassName.c_str();
wndClass.lpszMenuName = NULL;
wndClass.style = CS_CLASSDC;
RegisterClassEx(&wndClass);
mHWnd = CreateWindowEx(0, mWindowClassName.c_str(), mTitle.c_str(), WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, mHInst, this);
Which creates the following window:
Clicky[^]
Now the problem is, at the call to CreateWindowEx() , mWindowClassName.c_str() returns "Default Window Class" , and mTitle.c_str() returns "My window" - yet the window is still created without any title. I'm guessing this is probably due to a conflicting set of window style flags, but I can't for the life of me get it to work, regardless of what combination of flags I use. What else could be causing this to happen?
|
|
|
|
|
Sauce! wrote: wndClass.lpfnWndProc = &Window::msgRouter;
-shouldn't this be wndClass.lpfnWndProc = Window::msgRouter; ??
Btw i also notice that you do this:
Sauce! wrote: wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
however the window's background on your screenshot is blue. Does that maybe give a clue to anything?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I'm rendering to the window with directx and clearing the backbuffer to blue
as for the function pointers, they are equivalent. Either one works.
|
|
|
|
|
Ah, ok, i thought it was "just the basic window". What happens if you -after creating the window- use SetWindowText to set the title?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
That's a really good idea actually. Unfortunately it seems to have no effect still
|
|
|
|
|
Can it be that when you set this window for OpenGL/DX (can't recall which you said) it removes the title? Try to add a border like WS_THICKFRAME or such to your window.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
WS_THICKFRAME gives the window a thick frame as expected, however it doesn't affect the title in any way.
I've tried removing my DirectX code, yet the window remains without a title.
I'm tearing my hair out over this!!
|
|
|
|
|
With a few minor changes (to work in my environment), your code snippet worked fine for me.
LRESULT CALLBACK WndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
WNDCLASSEX wndClass;
wndClass.cbClsExtra = NULL;
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.cbWndExtra = NULL;
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.hCursor = ::LoadCursor(NULL, IDC_ARROW);
wndClass.hIcon = ::LoadIcon(NULL, IDI_APPLICATION);
wndClass.hIconSm = ::LoadIcon(NULL, IDI_APPLICATION);
wndClass.hInstance = AfxGetInstanceHandle();
wndClass.lpfnWndProc = WndProc;
wndClass.lpszClassName = "MyWndClass";
wndClass.lpszMenuName = NULL;
wndClass.style = CS_CLASSDC;
RegisterClassEx(&wndClass);
HWND mHWnd = CreateWindowEx(0, "MyWndClass", "MyTitle",
WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
NULL, NULL, AfxGetInstanceHandle(), this);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I'm thinking then that it has something to do with my msgRouter() or wndProc() - I've tried an empty wndProc that simply returns defWindowProc() with no luck.
LRESULT CALLBACK Window::msgRouter(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if(msg == WM_NCCREATE)
{
Window *window = reinterpret_cast<Window*>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<long>(window));
return TRUE;
}
else
{
Window *window = (Window*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
if(window)
{
return window->wndProc(msg, wParam, lParam);
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
LRESULT CALLBACK Window::wndProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
PostQuitMessage(0);
return 0;
default:
break;
}
break;
default:
break;
}
return DefWindowProc(mHWnd, msg, wParam, lParam);
}
|
|
|
|
|
I'm facepalming over this.
I really am.
I was just digging through MSDN docs on designing a window procedure, just for the hell of it.
It said the following: "The WM_NCCREATE message is sent just after your window is created, but if an application responds to this message by returning FALSE, CreateWindowEx function fails. The WM_CREATE message is sent after your window is already created."
I thought to myself, "hmm - maybe setWindowLong() is failing or doing something funny if the window only half-exists at this point. I'll try WM_CREATE instead"
lo and behold the title shows up!
msgRouter, fixed version:
LRESULT CALLBACK Window::msgRouter(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if(msg == WM_CREATE)
{
Window *window = reinterpret_cast<Window*>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<long>(window));
return TRUE;
}
else
{
Window *window = (Window*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
if(window)
{
return window->wndProc(msg, wParam, lParam);
}
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
|
|
|
|
|
(clap) (clap) (clap)
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I have the application which will send udp broadcast message.
And it is working fine xp. but in vista it is getting failed in release version.
Debug version working fine in vista.
what could be the problem ?
|
|
|
|
|
It can be an rights or firewall issue. Switch the Firewall off (for testing!!!) or are you debugging as Administrator?
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Firewall is switched off. and UAC is disabled. Running in administrator rights.
|
|
|
|
|
That sound really bad.
I dont have any clue so dig in the MSDN whether UDP-broadcast are not allowed
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi,
I am getting following error when running my application on visual studio 8."Error 1 error PRJ0019: A tool returned an error code from "Registering ActiveX Control...". Look like properties setting issue however not able to trace it exactly. Could you please help me.
Thanks
Pankaj
|
|
|
|
|
It should be somewhere inside tools->options Project->Properties->Custom Build Setup..."Post Build". Most likely the output file is configured to be registered using "regsvr32"
Suhredayan
modified on Thursday, December 17, 2009 1:09 AM
|
|
|
|
|
It is registering in Project->Properties-Custom Build Setup as
Command Line :-regsvr32 /s /c $(TargetPath)
echo regsvr32 exec. time > $(OutDir)\regsvr32.trg
Outputs :-$(OutDir)\regsvr32.trg
Do i need to modify or remove it? I aapreciate your time
Thanks
Pankaj
|
|
|
|
|
Does this[^] help?
-Suhredayan
|
|
|
|
|