|
Bitmap is not created. Interesting, why. What are nWidth and nHeight values? Try this:
Bitmap* pMemBitmap = new Bitmap(nWidth, nHeight, PixelFormat24bppRGB );
|
|
|
|
|
nWidth are right-left+1 in the rect returned by GetClientRect, and the similar goes for nHeight.
Using another Pixel Format didn't help, unfortunately.
|
|
|
|
|
>> nWidth are right-left+1 in the rect returned by GetClientRect, and the similar goes for nHeight.
I know, I asked what are their values in debugger? 10, 100 etc.
|
|
|
|
|
Sorry, my bad
nHeight = 654
nWidth = 1023
However, VStudio marks these values in red. Any particular reason?
|
|
|
|
|
They are marked in red because they are used in current program line.
I really don't have idea what happens. The last thing I can suggest is to see the whole project. If you can make it available for download, post me link to it. Or you can e-mail it to me.
|
|
|
|
|
Yeah, "check"'s in the mail :P
|
|
|
|
|
Move GDI+ initialization code in InitInstance to the place before creating of main frame. Currently it is placed after creating and showing of main frame, and first time view is redrawn, GDI+ is not initialized.
By the way, I didn't know that CodeProject allows to post e-mail with attachments. Since you mahaged to do this, you get an answer immidiately.
|
|
|
|
|
Works, thanks!
About the e-mail: I don't quite understand. I simply found your e-mail from the mail I got with the alert connected to this thread, and sendt you a ordinary mail
Thanks for all help!
|
|
|
|
|
Hi,
I was hoping I could get you to look at another problem I've been having with this double buffering...
It's posted elsewhere on the forum: Thread.
Could you maybe take a look at it, and give it a shot?
|
|
|
|
|
Hi,
How could I get the begin and the end of the hibernate event (if exist) on WinXP ?
I have to know when the user start ("turn off" the machine) and finish ("turn on" the machine again) the hibernate process.
Thanks,
Cris.
|
|
|
|
|
You could try handling the WM_POWERBROADCAST message.
|
|
|
|
|
Hello,
Can anyone provide me some ideas or resources in order to read the .PSD file? I am more interest to know how can I read the layer information of in the .PSD file.
Thanks!
Nachi
|
|
|
|
|
Go here and search for the PSD format.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
is there a way to place a drop menu nexto and image
|
|
|
|
|
I have an MFC application that creates a WH_GETMESSAGE with a callback function in an external non-MFC DLL. It specifically monitors mouse and keyboard events. Event notifications are sent to my app with PostMessage from inside the DLL callback function. This in itself works perfectly. However, when I try to close the app, the app will crash or start to take up 100% cpu usage. If I right click the app in the task bar and choose close, I get 100% cpu usage, or if I then press 'C' for the 'Close' menu option, the app crashes. The X button will crash, double clicking the icon in the titlebar will exit without error, as will Alt-F4, and choosing Close from the system menu will crash.
It doesn't matter if I uninstall the hook in OnClose or not, because the DLL will cleanup on DLL_PROCESS_DETACH. I get the same result anyway.
I'm very confused, I have no idea what the problem is, its not consistant at all. I do know that if in the DLL I comment out the PostMessage lines in the event callback, there are no crashes or hangs at all. So I don't know if my app or dll is to blaim. Before the GetMesssage hook I had separate mouse and keyboard hooks, which didn't cause the CPU hang, but would occassionally crash.
Any suggestions?
Thanks!
-Aaron
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Maybe the dll shouldn't notify the application in case the application was closing? (infinite loop?)
Try unloading the dll from the application first
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
The problem is I want the DLL running the entire time the app is, without some sort of stop button being requried.
I was wondering if there may be an infinite loop, and I think you're right, that that was the problem. What I did is add a conditional to my hook callback that would only postmessage if the orginator of the message was not my window. And that works great! I don't really need the messages to be posted while they're in my app anyway.
Thanks!
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Aaron Stubbendieck wrote:
I have an MFC application that creates a WH_GETMESSAGE with a callback function in an external non-MFC DLL. It specifically monitors mouse and keyboard events. Event notifications are sent to my app with PostMessage from inside the DLL callback function.
Uh oh. That there is an infinite loop waiting to happen. Your app calls GetMessage(), which triggers your hook, which posts a message to your app, which calls GetMessage() to read it, which triggers your hook, which posts a message to your app...
See where that's gonna end up going?
You'll have to find some other way of notifying your app - look at shared memory or some other inter-process communication; messages won't work in this case.
I can't really explain why some cases didn't cause the crash, although it may be due to the "feature" of WH_GETMESSAGE hooks where messages retrieved via GetMessage() are processed by the hook, but messages retrieved with PeekMessage() are not. I never really understood why this was the case, but it's possible PeekMessage() may be being used for some of those cases.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Yeah, I eventually worked around that by not posting the message if it was from my app, that's as clean of a solution I could come up with. The odd thing is, that except when closing the app, there was no problem.
Thanks for the help on this thread and the other.
modified 12-Jul-20 21:01pm.
|
|
|
|
|
how can I convert TCHAR to LPVOID
here the example what I have,
<br />
CString str = "HELLO"<br />
TCHAR k[512];<br />
wcscpy(k,(LPCTSTR)str);<br />
LPVOID lpmsg = k;<br />
could run without any problem, but lpmsg only contain only one character, which is 'H'
how can I store CString content to LPVOID or TCHAR to LPVOID.
Thankyou
|
|
|
|
|
Exactly like you did
If you want to see all the chars cast it back to a TCHAR*
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I dont' want to see all the characters back
I need to send this message to another application.
I have two applications, let's named them app1 and app2. They used pipe to communicate. So
app1 needs to send the message to app2 and here what app1 did,
<br />
CString msg = "sample text";<br />
LPVOID lpvMessage;<br />
TCHAR chBuf[512]; <br />
wcscpy(chBuf,(LPCTSTR)msg);<br />
lpvMessage = chbuf;<br />
int k = strlen((const char*)lpvMessage);<br />
<br />
fSuccess = WriteFile( hPipe,lpvMessage,strlen((const char*)lpvMessage) + 1, &cbWritten,NULL); <br />
app2 gets the message sent by app1 but only the first character.
So what I need is app1 has CString conent and need to send that string to app2.
How can I send that string out to app2?
by the way, I'm using UNICODE
thank you
|
|
|
|
|
How much is strlen((const char*)lpvMessage)??
and how are you reading the data in app2?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
strlen((const char*)lpvMessage) return 1
app2 reads as followed,
fSuccess = ReadFile( hPipe, chBuf,512,&cbRead, NULL);
chBuf only contains the first character of what app1 sent.
thank you
|
|
|
|
|
A tip:
wcscpy(chBuf,(LPCTSTR)msg);
+
int k = strlen((const char*)lpvMessage);
Krrrrrsh...
Would be the first time ANSI-routines would work for Unicode strings
Instead of using strlen, use _tcslen. Also, you shouldn't use wcscpy, but _tcscpy.
For the WriteFile function, use the length returned by _tcslen and multiply this size with sizeof(TCHAR) .
Best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|