|
Use LoadImage with the LR_LOADFROMFILE flag
HBITMAP bmp = (HBITMAP)LoadImage(NULL, _T("C:\\MyBitmap.bmp"), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hi!
I need to be able to control the life time of a window that was created in a different process. For that purpose I set a CBT-hook to check for the HCBT_DESTROYWND notification. The problem is that I only get notifications for destroyed windows that were created by threads in my own process.
The hook callback function is, as the docs request, in a separate dll.
I use this function call to set the hook:
::SetWindowsHookEx(WH_CBT, _CBTProc, hInstance, NULL);
Here, hInstance is the handle to the loaded separate dll and _CBTProc is the pointer to my callback inside that dll.
As I said: it works, I get notifications, but ONLY for windows owned by threads in my process. That's not what I consider a "system wide" hook!
As a workaround I also tried to get the ID of thread owning the window I want to be informed about via GetWindowThreadProcessID() and used that ID instead of the NULL parameter when setting the hook - to no avail...
In this same separate dll I use a system wide mouse hook. This mouse hook _does_ work however.
So my question is: did I miss something important concerning CBT hooks? How can I get a really system wide CBT hook installed?
Thanks in advance
Nick
|
|
|
|
|
Hello,
I want to scroll the content (among other things) and I would like to use CScrollView class that already handles all the bulk of the code.
The question is: Can a View as CFormView used without an atached Doc and a Frame?, that's it appart of Doc/View architecture.
Thanks in advanced.
|
|
|
|
|
I believe it can't, but that doesn't mean you're stuck: simply create an "empty" document class. To add the view to that document, you can either do it manually, or even better: create a document template.
You can create the document using the class-wizard, which is a snap. The template you simply instanciate with the run-time classes of the document and the view.
-- Nitzan
|
|
|
|
|
I've made my application in Visual C++ 6.0 using the MFC.
One of users is reporting that application is crashing with the "Runtime Error! Program: C:\.....\..exe abnormal program termination", I can't reproduce this bug on my computer.
When the runtime shows this message box ? There is no address of crashing code,
so I can't find the problem
What to do ?
Thanks
rrrado
|
|
|
|
|
Nothing definitive, but:
Does it crash often, or was it a one-time thing?
Does it crash in the same place (e.g., opening of a certain file, rendering of a particular graphic) everytime?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
It crashes every time and always at the same place.
But if I try to make the same steps which leads to crash on
my computer, everything is working correctly.
I can't visit the user with the debugger
rrrado
|
|
|
|
|
rrrado wrote:
It crashes every time and always at the same place.
Perhaps you could add some debugging code (message box, or a log file) to that particular area of the program.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
maybe I'll have to do so,
but it's probably inside quite complex function running in worker thread,
calling lot of functions, which are operating with strings, network and database
It would be so many messages
rrrado
|
|
|
|
|
I did not say it would be easy, unfortunately. The only thing I can offer that might expedite your time is a macro. It's bulky, but the goal is to squelch a bug, not operate at maximum efficiency, right?
#define LOG(x) {FILE *p=fopen(..., "a");fprintf(p, "%s\n", x);fclose(p);}
...
LOG("Starting abc task"); This is just an example. You might want to tweak it so that variables and such can be output, too.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
good idea to write it into file thanx
rrrado
|
|
|
|
|
Let's just hope that the file I/O does not mask the problem.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I think you get that message after someone has called 'abort'. And 'abort' can get called when an exception is thrown inside an exception handler or when a C++ exception isn't caught at all.
So if you're using exception handling it's worth reviewing it. And if you're not it's worth looking at whether any of the libraries you're using are, and trying some try/catch stuff...
Paul
|
|
|
|
|
Thanks for suggestion, I didn't know that unhandled exceptions are making this.
I'm not using exception handlig, it seems to be much more difficult to use than good old return value errors.
I'll try to make some TRY CATK on whole function
rrrado
|
|
|
|
|
if it was an exeption, you should have the error message like this : unhandled exception 0x...... at....
TOXCCT >>> GEII power
|
|
|
|
|
That's what you get under the debugger. In a release build running alone using VC7.1 you get a message box containing,
"Runtime error!
This program has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information"
Paul
|
|
|
|
|
no, the message i described was a Windows generated messageBox...
TOXCCT >>> GEII power
|
|
|
|
|
Yes but it only appears if visual studio is intalled on the computer (because it asks you if you want to debug the code).
|
|
|
|
|
hiiiiiii
can anybody telll me how can i pick the RGB value from an image on "onMouseOver event" and how can i show them in edit boxes.
|
|
|
|
|
Try to get your control's device context and use GetPixel()
rrrado
|
|
|
|
|
GetRValue, GetBValue and GetGValue are used to get the color from the return value of GetPixel()
Don't try it, just do it!
|
|
|
|
|
thanx Alexander
canu give me the code so that it will help me alot coz i m a bit new to VC++
its a bit urgent dear.
waiting for ur reply
thanx again
bye
regards
tahir
|
|
|
|
|
Hi,
I have a question regarding reading and writing to the same (text)file. I know it is not Visual C++ (just C++) but I still hope someone will respond.
I have a project which I run from the command promp. The same exe file is run twice, with different parameters sent to the main() function, so that I have two dos windows open at the same time.
Below P1 is the first program and P2 the second program.
P1 output file is P2 inputfile and vice versa.
P1 reads a line with cin and then output it to a file. P2 does the same.
Everything works fine so far but...
...the question is how I would code a loop so that P1 reads a line from P2 output file with i.e. getline() until the textfile is updated(changed) by P2 and ONLY then print it out on P1 screen and vice versa???
This might seem to be a stupid program but it is for studying purpose.
Thanks in advance for any hints or solutions
Regards
Lars
|
|
|
|
|
I've never tried it, but I'm sure that there's some function in windows API which will setup notifications for you when choosen file is changed.
(most of the editors use this to reload the file when it's modified outside the editor,
maybe you would find this in wordpad sample soure code)
rrrado
|
|
|
|
|
But I think better way to send data from one program to another is using the pipe (p1.exe | p2.exe - stdin of p2 is connected to stdout of p1), but I've tried this only in unix, I'm not sure how will this run in Win)
rrrado
|
|
|
|