|
if you allocate memory via new operator
then you have to delete it via delete operator
otherwise memory will be leaked
in ur case delete pbmp
would be done in OnDestroy
pbmp should not be a local variable (define it in class)
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
I See.
Thank u!
Please use your head again.
if u have another good way, please tell me immediately.
Hello World!
|
|
|
|
|
why are you using new ?
in class
do
CBitmap bmp;
in Constructor
do - bmp.LoadBitmap(MY_BMP);
then
in OnInitDialog
pic.SetBitmap(&bmp);
Done!
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
if so, how to do?
i don't want to add many global variables.
Could u have some useful way?
Thank u!
Hello World!
|
|
|
|
|
i learn a little about smart points,
but i don't know how to do.
could u tell me?
Thank u!
Hello World!
|
|
|
|
|
Using one of the teach-yourself-you-dummie books I entered the following code to creat a window. It compiles just fine, without error or warning. But once I execute it my CPU usage pegs at 100%, the small Icon does not render, and clicking the close button fails to close the window.
#include <windows.h><br />
<br />
LRESULT CALLBACK fnMessageProcessor (HWND, UINT, WPARAM, LPARAM);<br />
<br />
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine,<br />
int iCmdShow)<br />
<br />
{<br />
HWND hWnd;<br />
MSG msg;<br />
WNDCLASSEX wndclass;<br />
<br />
wndclass.cbSize =sizeof(WNDCLASSEX);<br />
wndclass.style =CS_HREDRAW | CS_VREDRAW;<br />
wndclass.lpfnWndProc =fnMessageProcessor;<br />
wndclass.cbClsExtra =0;<br />
wndclass.cbWndExtra =0;<br />
wndclass.hInstance =hInstance;<br />
wndclass.hIcon =LoadIcon(NULL, IDI_APPLICATION);<br />
wndclass.hCursor =LoadCursor(NULL, IDC_ARROW);<br />
wndclass.hbrBackground=(HBRUSH) GetStockObject (GRAY_BRUSH);<br />
wndclass.lpszMenuName=NULL;<br />
wndclass.lpszClassName="Window Class";<br />
<br />
wndclass.hIconSm =LoadIcon(NULL,IDI_APPLICATION);<br />
<br />
if(RegisterClassEx(&wndclass)==0)<br />
{<br />
exit(1);<br />
}<br />
<br />
hWnd=CreateWindowEx(<br />
WS_EX_OVERLAPPEDWINDOW,<br />
"Window Class",
"Create Window Example",
WS_OVERLAPPEDWINDOW,<br />
0,<br />
0,<br />
400,<br />
600,<br />
NULL,<br />
NULL,<br />
hInstance,<br />
NULL);<br />
<br />
ShowWindow(hWnd, iCmdShow);<br />
<br />
while(GetMessage (&msg,NULL,0,0));<br />
{<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
<br />
return (msg.wParam);<br />
<br />
}<br />
<br />
LRESULT CALLBACK fnMessageProcessor(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch(iMsg)<br />
{<br />
case WM_CREATE:<br />
return(0);<br />
case WM_PAINT:<br />
return(0);<br />
case WM_DESTROY:<br />
PostQuitMessage(0);<br />
return(0);<br />
default:<br />
return DefWindowProc(hWnd, iMsg, wParam, lParam);<br />
}<br />
}<br />
Do any of you have any observations about the code and or any suggestion to overcome this buggy behavior?
Thanks all.
Best,
Jerry
The only way of discovering the limits of the possible is to venture a little past them into the impossible.--Arthur C. Clark Toasty0.com
|
|
|
|
|
Everything looks prety good to me
Maybe try commenting out DefWindowProc() and compiling...see what happens
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
I'm pretty sure you need to add the following code to your WM_PAINT case:
PAINTSTRUCT a_stPaint;
BeginPaint( hWnd, &a_stPaint );
EndPaint( hWnd, &a_stPaint );
It's been a while since I did raw Win32, so I'm not certain.
Chris Richardson
|
|
|
|
|
in WM_CREATE and WM_PAINT ...
don't return 0 do a break;
and call DefwindowProc
might help
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
This gets weirder and weirder.
I created a new solution (workspace). Copy&pasted the code into a new .cpp file, compile and executed and all worked just fine.
Can we say, "things that make you go hmmm?"
Thanks for all the suggestions and help.
Best,
Jerry
The only way of discovering the limits of the possible is to venture a little past them into the impossible.--Arthur C. Clark Toasty0.com
|
|
|
|
|
TranslateMessage() and DispatchMessage() are never getting called. Why? Because your while loop does nothing thanks to the common error of an extra semicolon.
Your message pump is effectively:
while (GetMessage(&msg, NULL, 0, 0))
;
|
|
|
|
|
I have a atl com service that need to do something on windows log off and lock event.
I created a winlogon dll to sendmessage to service for the above events.
STA Service is not getting those messages.
How to detect logoff and lock event from atl COM Service
Chak
|
|
|
|
|
Hi Chak.
> How to detect logoff and lock event from atl COM Service
It's easy with logoff - simply call SetConsoleCtrlHandler and catch the CTRL_LOGOFF_EVENT .
Lock events are trickier. I guess the easiest way to catch them is via a Winlogon Notification Package[^].
Note: Because the notification Dll gets loaded by Winlogon and because Winlogon is running under the local System account (your COM Service probably isn't?), you can't use the SendMessage API as a means of IPC communication between them. Try memory mapped files or named pipes instead. Also, set the Impersonate[^] reg-value of your notification Dll to 1 or modify the Dacl of your memory mapped file/named pipe appropriately (check this: A NotQuiteNullDacl Class[^]).
RK
PS: This were just presumptions from the top of my head -> for the exact behavior/terminology and implementation check the MSDN documentation.
|
|
|
|
|
I am using the CSocket class with all the CSocketFile and CArchive stuff (mainly based on the MFC samples). The problem now is, that, after some time, the socket won't receive anything (well, it receives it, but it still stops at some point).
When receiving the data with CAsyncSocket::Receive, it won't stop, so I guess it's a problem with either CSocket or CArchive/CSocketFile. The funny thing is that the MFC samples have the same problem... and it's not just my computer
So is there any known solution to this or do I have to go a different direction without archives?
And yes, I used IsBufferEmpty()...
|
|
|
|
|
Is there a simple way to emulate console mode on a GUI form or dialog box? Perhaps an article or control somewhere? Would it be logical to create one as a derived Rich Text box?
Sincerely,
Ray Gregory
|
|
|
|
|
All a console is (as far as look) is a window with a fixed width font.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I think it would be probably easier to write your own control for it. If you use the rich text box, you'll be spending lots of code to restrict it rather than extending it. After all, a rich text edit box is text editing control, while a "console" is a line-editing tool combined with static output.
--
Sancte Míchael Archángele, defénde nos in proélio contra nequítiam et
insídias diáboli esto præsídium. Imperet illi Deus, súpplices deprecámur:
tuque, princeps milítiæ cæléstis, Sátanam aliósque spíritus malígnos, qui
ad perditiónem animárum pervagántur in mundo, divína virtúte,
In inférnum detrude. Amen.
|
|
|
|
|
Hi,
I wrote a c++ dll containing a CWnd, which is created an displayed when the dll is loaded by an application. When I use the dll with a c++ app or a VB app everything works fine, window is created and displayed as planned, but when i load the dll from a java application the window seems not to be created correctly.
Any ideas what might be the problem?
|
|
|
|
|
Hi,
i recommand to use statically linked regular DLL.If you choose statically linked DLL it includes copy all the needed MFC library code with in your DLL. So, it size is more. If you choose dynamic linked library the memory space is less compare then static linked library regular DLL. But, you will use proper DLL version in the target machine.
Regards,
R.Selvam
|
|
|
|
|
As you will all surely know C# has this cool interface where you can
put XML into the comment blocks of your code, and have it automatically
generated as a web page of comments (especially using a tool like NDoc.)
This gives you a nice class documentation web page heirarchy.
I have a bunch of code that uses DOxygen style coding for inserting
similar stuff into my C++ code, however, I want to use the same techinques
in C++ that I do in C#. Specifically, I want to be able to type in the
comments directly when I use the class view to insert code, and I want
to be able to use NDoc to generate the pages.
I know about DOxygen, in fact I use it, however, I want to get on the
same page as C# with my C++ code for consistency and simplicity (and
by way of the fact that surely future versions of Visual Studio will
head that direction.)
I suppose I want to use NDoc with C++.
any thoughts or suggestions.
|
|
|
|
|
How can I set the tab focus to a specific control in a dialog box.
Thanks
|
|
|
|
|
SetFocus() .
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
In your dialog class, where you want to set the focus to a control, try this:
GetDlgItem( ID_OF_CONTROL )->SetFocus();
|
|
|
|
|
I'm trying to implement the ability to drag and drop a file onto a tree control, BUT it would be great if you could only drag onto certain objects. Is there a way to allow the user to drag a file onto the tree control and depending on what type of object the user drags the file over, drag and drop is allowed or disallowed?
It would be flimsy for them to have to select a tree item then drag and drop, much nicer if you simply drag the file to the object you want to add it to and if its allowed, it works!
|
|
|
|
|
When your IDropTarget::DragOver() method is called, you get a POINTL holding the cursor location. Convert that from screen coords to client coords (relative to the tree) then use TVM_HITTEST to find out which tree item that point is over.
Once you get that, you can decide whether to allow the drop over that item. Return DROPEFFECT_NONE to not allow it, or DROPEFFECT_MOVE /COPY to allow it.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"
-- Rico Mariani, CLR perf guy
|
|
|
|