|
As Nishant explains in his article a modal dialog makes a call to DestroyWindow() and as a result to PostNcDestroy().
But in your example you are building a modeless dialog and Windows is very specific about this case. You need to call DestroyWindow() to close a modeless dialog. Why? I don't know. This decision was made by windows. I will do a little bit of investigating though to find out. However, in this case OnClose() doesn't generate an WM_DESTROY message afterwards.
And by the way this part of your code
DestroyWindow();
CDialog::OnClose();
generates an exception because you are sending a WM_CLOSE message to a window that doesn't exist.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
I have a hierarchy of ListCtrl-derived classes. Everything is working fine, except when OnDestroy is called, it seems to be called in the wrong order, for an object of type CList2:
eg.
class CList1 : public CListCrtl
{
}
class CList2 : public CList1
{
}
Am I missing something really obvious here, or is this correct?
There are 10 kinds of people - those that get binary and those that don't.
|
|
|
|
|
How many objects did you instantiate? What were they?
Kuphryn
|
|
|
|
|
kuphryn wrote:
ForumVisual C++
Subject:Re: OnDestroy called for base class first...
Sender:kuphryn
Date:15:39 13 Jun '03
How many objects did you instantiate? What were they?
Only one, the last one in the hierarchy.
I think I've found my problem - it all comes down to a design that didn't take into account the customers next move...
Basically, I'm trying to fit a square peg in a round hole, and it isn't working at all.
Thanks for replying anyway...
There are 10 kinds of people - those that get binary and those that don't.
|
|
|
|
|
I have a DLL called exceptions.
Now, if I add STL string parameters to its parameter list, my code crashes after entering into the code and after the code is complete....
i.e.
dll file:
class dll_export(delspec) CExcpetions
{
CExceptions();
CExceptions(std::string str);
}
cpp files
using namespace std;
CExceptions::CExceptions()
{
}
CExceptions::CExceptions(string str)
{
/// do something
}
///the calling exe
if( i == 1)
throw CException ("Hello");
As soon as it exits the constructor method,it throws an error.
Any ideas?
|
|
|
|
|
see the MSDN. there are a couple of STL + DLL articles there.
these two in particular might be helpful:
Q172396
Q168958
-c
To vote with no response is to follow the way of the coward.
|
|
|
|
|
It seems to work with vector and maps, but when I try the following with strings it doens't compile:
#ifdef EXP_STL
# define DECLSPECIFIER __declspec(dllexport)
# define EXPIMP_TEMPLATE
#else
# define DECLSPECIFIER __declspec(dllimport)
# define EXPIMP_TEMPLATE extern
#endif
EXPIMP_TEMPLATE template class DECLSPECIFIER std::vector<int>; -- good
EXPIMP_TEMPLATE template class DECLSPECIFIER std::vector<char>; -- good
EXPIMP_TEMPLATE template class DECLSPECIFIER std::string; --fails to compile
Gives the following error:
error C2242: typedef name cannot follow class/struct/union
|
|
|
|
|
actually an interesting observation.
If I pass string by value (i.e void method (std::string x), it crashes.
If I pass string by reference (i.e. void method (const std::string & x),it does not crash.
take care
|
|
|
|
|
Assuming that you are using Visual Studio 6, download the patches to the STL it shipped with from www.dinkumware.com.
|
|
|
|
|
Every files has header which contains all information about the file.
Is there any function that read files' header.
Can I tell which application file to use to print/view the file base on the information of the file??
for example, I craeted test.txt file using notepad. then I rename the file as temp.t.
Is there any function to tell temp.t can open with notepad??
|
|
|
|
|
pnpfriend wrote:
Every files has header which contains all information about the file.
Not necessarily. It depends on the application that was used to create the file.
pnpfriend wrote:
Is there any function that read files' header.
Not a function per se, but there are a plethora of utility-like applications that do this. They're usually created on as as-needed basis.
pnpfriend wrote:
Is there any function to tell temp.t can open with notepad??
FindExecutable()
|
|
|
|
|
<br />
Not a function per se, but there are a plethora of utility-like applications that do this. They're usually created on as as-needed basis.
can you explain it to me again please.
What about By_HANDLE_FILE_INFORMATION structure?? nNumberOfLinks seem likes what I need.. but I dont' know how to use it..
Thank
|
|
|
|
|
pnpfriend wrote:
nNumberOfLinks seem likes what I need...
I doubt it, but here's an example:
HANDLE hf;
BY_HANDLE_FILE_INFORMATION bhi;
hf = CreateFile("somefile", GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE != hf)
{
if (GetFileInformationByHandle(hf, &bhi) == TRUE)
printf("Links = %lu\n", bhi.nNumberOfLinks);
CloseHandle(hf);
}
|
|
|
|
|
you are right.. it's not what I want.
So there is no function that will get the file header and can tell what associate file to use eventhough the file doesn't have the extension.
I tried FindExecutable(), it can't tell what associate file to use if the file doesn't have extension or that extension didn't register.
Is it possible to tell what associate file to use base on what's in the file header???
|
|
|
|
|
pnpfriend wrote:
Is it possible to tell what associate file to use base on what's in the file header???
Technically, yes, but it would be a guessing game at best. There are as many file types as there are grains of sand on the beach (in theory, anyway). You'd have to code all of the permutations of what header (assuming you could even get the format of the header) went with what app, and then if a new one was introduced...well, you get the idea. It's just not somnething you could do with any hope of success.
|
|
|
|
|
huuuu... sound like there is no way I can actually use the file header to determind the associated file.
one final question, how to get the file header? Is there a function to get the file header?? When I mean getting file header, I meant getting all possible information about the file.
Thank You Dave
|
|
|
|
|
Every file's format is different and unique unto itself. Some files don't even have a "header" but just contain raw data.
pnpfriend wrote:
When I mean getting file header, I meant getting all possible information about the file.
Depending on what you mean by "all possible information," some information about a file can be obtained with GetFileAttributes[Ex], as well as StgOpenStorageEx() for summary-type information.
|
|
|
|
|
As david said not every file has a header. There are as many file formats as grains of sand. I myself have invented at least a dozen file formats. There is no standard format for a header. You must know how to decode the file to read the header in most cases.
John
|
|
|
|
|
thank you both for your explaination.
|
|
|
|
|
Decode!!!
Can you please give me some example in decoding for one file?
for example, a pdf file.
I have to read in binary right. and then I really don't know how to continue from there.
|
|
|
|
|
For PDF search the internet for ghostscript. You do not want to write decoders for all file types. Writing one for PDF alone should take a person several months work. I was just thinking depending on what information you need you might be able to get the info you need from the pdf file without decoding the whole file.
John
|
|
|
|
|
Oh.. I think I misunderstood you saying decode.
here is my plan to know the file creator.
I need to collect all magic number or creator of each and every file and crate the list or table. for example,
file magic numbers
Then I will read may be first 100 byte of the file and see if i can find any magic number that exits in the table. By doing so, I can tell the file is created with the particular application.
So I don't have to worry about whether there is a file extension or weird file extension of the file. but I can still view/print the file with the correct application.
|
|
|
|
|
Ok. That will work for some file types but by no means all. A PDF file should always start with %PDF.
John
|
|
|
|
|
Ok. I thought you were still trying to extract the author and other properties from the file.
John
|
|
|
|
|
no I'm not going to change anything to the file but only to identify the creator of the file which doesn't have file extension.
so can i rely on the magic number of the file to identify the creator?
|
|
|
|