|
Thank you very much. That is my missing link.
|
|
|
|
|
maybe:
Use ::FindWindow() to check if the other program is running, and get the window handle if it is.
Use something like ::SetFocus() or ::SetForegroundWindow() to give the other program control (now that you have its window handle).
|
|
|
|
|
DjinnKahn wrote: Use ::FindWindow()...
...to cause a potential deadlock situation.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
So I don't use FindWindow(). If I would use something better, how could I give focus?
|
|
|
|
|
Hi.
I want to know how I can create an array/object at runtime if I don’t know about its data type.
For example,
I have an array Say Arr, but I don’t have any information about the data type of elements it stores. It might be an array of int, float, char or even user defined data type (user defined class).
I can get the information about its class or data type by using ‘type_info’, but how can I create an array/object of same data type at runtime?
Like if I want to copy the contents of an array Arr into another array say ‘NewArr’; of the same type at runtime, how can I create that second array NewArr, i.e. what should I specify as a data type of ‘NewArr’?
Thanks
Sameer Thakur
|
|
|
|
|
Sounds like a job for a template .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Sameer_Thakur wrote: how can I create an array/object of same data type at runtime?
AFAIK, there's no way to do this directly in C++.
You can, however, design a system of classes that are capable of creating/cloning themselves at
runtime and/or being created by type.
For an example implementation, check out the source code for MFC's CRuntimeClass and CObject
classes and the DECLARE_DYNAMIC/IMPLEMENT_DYNAMIC macros. This implementation has a common
base class which includes methods for runtime object creation based on a class name.
Because C++ has no built-in way to do this, the CRuntimeClass implements a list that maps
class names to creator functions.
Depending on the source of your source arrays, serialization may be useful as well.
Regardless, at the heart of these solutions is code that creates objects of a specific class,
which is all that C++ allows.
Just my 2-cents,
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I am trying to create a custom window caption for SDI application.I have
taken help from http://www.codeproject.com/gdi/customcaption.asp
The project on the above link use WM_NCPAINT,WM_NCACTIVATE and WM_SETTEXT handlers in the window procedure to draw and paint the caption bar.In this
project whole caption bar has been customized.
In my application,I don't want to draw and paint minimize,maximize and close buttons and let them be like the system's created default buttons.Actually these default buttons are getting drawn and painted but are not visible when the mainframe window gets activated.When I move the mouse on that region, then only those buttons are visible and work fine on clicking them.So, Can you please suggest me why those buttons may not be getting visible when the mainframe window gets activated?
With Regards
Neeraj Sinha
|
|
|
|
|
Have you checked out if button->ShowWindow (TRUE) works?
It would help if you post a bit of your code.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Hi everyone
i am developing a com add-in for MSWord in MFC, and i need to get the current UI language of the MSWord to make it the UI language of the add-in
i know that there is a method in the application class called get_LangaugeSetting , but in MFC this will retrun a dispatch, i need the LanguageSettings class to attach it with the dispatch
and i dont know where to get this class from
any help please
thanks all
|
|
|
|
|
I am creating a dialog based application with a CWebBrowser2 control. I need to print the page displayed in the browser in landscape or portrait format without displaying the PrintDialog. Landscape or Portrait is decided by some other inputs.
I have two methods in my App class for setting the orientation and for starting the printing. Now the probelm for me is how to get the content in the browser or in other words how to get the html displayed in the browser? what to do after a m_Browser.GetDocument() call ?? I dont know how I can associate the html with DOCINFO structure ( setting the file name does not work of course). Landscape/Portrait modes and a dc.TextOut() for a hardcoded string works fine. But how to print the html displayed in the browser?
Please note: setting the orientation and using the ExecWb() function does not work because I am always getting portrait mode only.
Excpecting your valuable comments. Thanks.
|
|
|
|
|
Guys....any tips regarding this ?? Setting printing orientation, getting the content from a Webbrowser control and printing it. I dont want the print dialog to appear and the ExecWb() method always prints in portrait.
|
|
|
|
|
Hi ! I?'ve an application developed using MFC. When I run the project, a window will open. If I close the window manually (i.e by clicking the cross mark at the top left corner of the window), then an exception occurs.
It states:
Unhandled exception at 0x7c918fea in Perspective.exe: 0xC0000005: Access violation writing location 0x00000010.
If I break this exception,
Program control goes to a file called free.c
How do I resolve this Exception?
|
|
|
|
|
Check call stack you will be deleting some memory which is already freed or not allocated. May be Pointer will have some gabage value which you are trying to free.
|
|
|
|
|
As sugeested earlier, it may be due to incorrect handling of memory, or writting out of bounds.
Run app in debug mode. See if call stack helps you.
Prasad
MS MVP - VC++
|
|
|
|
|
How to view the call Stack? There is no tool bar icon for Call Stack in the VC++ Editor.
|
|
|
|
|
Use Alt+7.
Prasad
MS MVP - VC++
|
|
|
|
|
I used Alt+7 but it did not show the call stack. I tried Alt+F7 also. It also did not work.
This Project is developed using Visual Studio .Net 2003. The editor has a yellow arrow mark. If I click this, the Disassembly window opens. Is this the call stack U mean?
|
|
|
|
|
In my VS version the shortcut is CTRL+ALT+C .
But firsly stop the program in DEBUG mode on a breakpoint.
Russell
|
|
|
|
|
Thanks. It is working(Call Stack Opens). But How to find out at which statement the problem occurs?
There are two markers(One Yellow Arrow and One Green Triangle). What do these markers really mean? Will these markers be helpful in resolving the exception?
The Yellow Arrow stops at this line:
ntdll.dll!7c918fea()
More over, the above said line and following the three lines are gray in color.
The Green Triangle Stops at this line:
msvcr71d.dll!_free_base(void* pblock = 0x00600c08) Line 103 Language C
The above said line is in Normal Color(Black).
|
|
|
|
|
the yellow arrow shows what file/function you are watching in VS, look at that!...and walk forward on the tree to find a function in your code (not in external dll) that do something wrong (than double cliche on that function on the call stack window).
Usually the error is in the first function that you will reach, and usually the real error could be in less than 10 lines before the line related to the crash...but it depends on your code.
Russell
|
|
|
|
|
Thanks a lot.
I clicked all the lines from the beginning of Call Stack. When I Click a New
Line the Green Triangle goes either to a system file(like free.c) or to a inline file(.inl file like nicriticalsection.inl).
ni stands for Net Immerse Game Engine(previously called NetImmerse New Name is Gamebryo).
It did not go to any of the function defined by me. I should not change any ofthese system files or inline files. They are predefined. What to do?
|
|
|
|
|
If ALL the lines (on the call stack window) are external to your project (very strange, becouse this means that your program it is not running ) then you can run the app 'step by step' (F10, or 'step in' F11, in debug mode) the program to find out what function cause the crash.
But I think you have to look better the call stack: 99.9% the error is in your code
Russell
|
|
|
|
|
I tried step by step execution also(by pressing F10). Yellow Arrow moves to some of the system file like free.c,dbgheap.c,stdenv.c,crtlib.c,appui3.cpp and finally to disassembly.
If I continue this step by step execution(F10) from disassembly, once all the
lines are completed the Yellow marker moves to the file where it initially started(i.e this file is also not my file. It is system file only). If I execute step by step(like you said), the window did not open. But usually when run I run the program in debug or release mode, a window will open.
We can do all the operations defined(like loading an image file, moving or rotating an object, setting the visiblity of an object on or off). If I close the window using the cross mark on the top left corner, then only that exception occurs. If terminate the excecution using stop button in the tool bar no exception is thrown.
What to do?
|
|
|
|
|
You need to pause the application one second before the crash...and then use debug tool like F10 or F11 to understand why it crashes. And do this, of course, before that the program exit from your code and goes to external dll(s).
You said that the exception comes when you close the application using the cross on the top right of the window....USE THIS INFO! Go to OnClose() (put there a brakpoint) and run the application step by step F10, F11.
Another thing: pressing the stop button in the VS toolbar will terminate the DEBUG mode, and it destroy the application, so no exception can occuors, beaouse NO CODE will run.
Russell
|
|
|
|