|
in
// the array of fonts
std::vector m_fonts;
// the strings to be rendered
std::vector m_strings;
the first is the template of LFont and the second of LStringData (the < and > are missing in the post)
|
|
|
|
|
In my OnClose I save a bunch of stuff to the registry.
int res = RegCreateKeyEx(keyHandle1, "ABC", 0, "",
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
&keyHandle2, &disp);
if<code>(!res)</code>
{
AfxMessageBox ("exiting");
CMDIFrameWnd::OnClose();
}
I know its better to say res != ERROR_SUCCESS, but anyways in the above if the key gets created or opened I want to exit the app. There is more code after this block. If I run as is, it crashes. I thought CMDIFrameWnd::OnClose(); would terminate the app...? Do I need to call PostQuitMessage explicitly?
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
I thought CMDIFrameWnd::OnClose(); would terminate the app..
No, it just closes the window. If you don't want to execute the rest of your code add a return; after CMDIFrameWnd::OnClose();
--
karl
|
|
|
|
|
First, as you said, typing if(!res) is bad practice. You should apply unary negation operator only to boolean expressions. FYI, C# prohibits such code.
But your question was not about that. I'd suggest using PostQuitMessage, 'cause OnClose is a simple message handler. It contains only code relevant to closing frame window, so semantically it is not the same as quitting the application.
However, I'm not sure if replacing OnClose with PostQuitMessage is going to solve the problem. Since the application crashes, it's most likely something else. Why don't you run it through debugger, step by step, and see where it crashes? Usually this helps.
Вагиф Абилов
MCP (Visual C++)
Oslo, Norway
Hex is for sissies. Real men use binary. And the most hardcore types use only zeros - uppercase zeros and lowercase zeros.
Tomasz Sowinski
|
|
|
|
|
Thanks! I shall test further....
Appreciate your help,
ns
Once I put in the return in the if block, it didnt crash....so apparently I shouldnt try to execute any more code after OnCLose is called...
|
|
|
|
|
hello,
i'd like to convert rtf files into standard bitmap format, like bmp or jpeg.
the solution i have now is to open the rtf and print with a simulated windows
printed which generates a bitmap. but it would be good to find a direct solution,
maybe someone knows how to do this, or a product/library, which can do this?
thanks
enrico
|
|
|
|
|
Sir, I want to access Webcam by capturing images through VC++. How can I do it???
C.R.Naik
|
|
|
|
|
There are image capture examples in the DirectX SDK
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Would you please tell me from where can I get that help and example?
C.R.Naik
|
|
|
|
|
I am using MS Word automation in my C++ project to create a Word document that contains several tables. I've been able to create the document and give it a specific format such as font sizes, paragrpah aligment...
My problem is that i am not capable of center a table. This is the code i use:
//get the range
oRange = oSelection.GetRange();
oTables = Doc.GetTables();
//try to center the paragraph where the table will be placed
oParagraphs=oRange.GetParagraphs();
oParagraphs.SetAlignment(1);
// Create a 5x5 table
oTable = oTables.Add(oRange,5,5,covTrue,covTrue);
But this doesn't seem to work, the table appears with left aligment.
Has anyone tried to center a table?
Thanks
|
|
|
|
|
Hi, everyone!
Look at the following codes,
--------
const char* p = "12345";
char* q = "54321";
--------
If I want to release the memory, should I use
--------
delete[] p;
delete[] q;
--------
or should I use
--------
delete p;
delete q;
--------
Thanks in advance,
George
|
|
|
|
|
You don't need to release the memory of these variables because they aren't allocated on heap but on stack. Defining char* q ="54321"; is the same as defining char q[6] = "54321"; .
You only need to use delete/delete [] for variables created with new/new [].
--
karl
|
|
|
|
|
Thanks, karl buddies!
George
|
|
|
|
|
Rule of thumb: You did not call new , you do not need to call delete .
For
char* r = new char[MAX_PATH+1];
you would call
delete[] r;
since you did a new[] .
But this is one of the cases where it does not matter, since char is an integral type and as such has no constructor or destructor.
The difference between delete and delete[] is that delete[] calls the destructor of every item to be deleted, whereas delete calls only the destructor of the first item.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks, jhwurmbach buddies!
George
|
|
|
|
|
jhwurmbach wrote:
But this is one of the cases where it does not matter, since char is an integral type and as such has no constructor or destructor.
This is true on most, but not all compilers. According to the standard, new must be deleted, and new[] delete[]'d.
There is no guarantee that the compiler implements new[] "on top of" new. It could even use different heaps for that!
Nur wer feige ist tötet Liebe durch das Wort allein [sighist] | [Agile Programming] [doxygen] If you look for evil in me you will find it whether it's there or not.
|
|
|
|
|
Thanks, peterchen buddie!
George
|
|
|
|
|
confused:hi all,
as we know..Internet Explorer stores information entered in the single fields of form when we submit it, so next time when you are filling the field with the same name, we are able to select value from dropdown list. I need a function that has field name as it's parameter and returns array of values stored in IE (so, I need to find where and how this information is being stored.) any help and any ideas are most welcome...
thanks in advance..
Himanshu
|
|
|
|
|
Hello!
Depending on your OS, but on NT the values are stored in the registry at
HKEY CURRENT USER\Software\Microsoft\Internet Explorer\IntelliForms\SPW
Unfortunally they are encrypted ...
You will find some info at
http://www.crazytrain.com/autocomplete.html[^]
Mike Eriksson
Sonork 100.21825
|
|
|
|
|
Hi everybody,
For a CListCtrl with the report style, is there an easy way to prevent the user from resizing the column headers? I was hoping there would be a style setting for this, but I can't find it.
Thanks a lot.
Ren
|
|
|
|
|
I am not 100% sure about this, but you need to handle the HDN_BEGINDRAG message (?) and return FALSE. I seem to recall this from somewhere.
Hope its of help.
Roger Allen
Sonork 100.10016
WHats brown and sticky?
A stick or some smelly stuff!
|
|
|
|
|
You need to handle the HDN_BEGINTRACK notification sent by the list's header control, and return TRUE to disable resizing.
[edit]changed FALSE to TRUE above (whoops!)[/edit]
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
If you implement a notification handler for HDN_BEGINTRACK and within that function set *pResult = TRUE, that will prevent the header sizing from happening. Unfortunately, the handler for HDN_DIVIDERDBLCLICK does not allow this override, so header sizing can still happen if the user double clicks a header divider. I don't know a way to change this behavior.
Ron Ward
|
|
|
|
|
Hi,
I tried this, but nothing seems to happen. Resizing is still possible.
I just used the classwizard to add a handler for =HDN_BEGINTRACK and made the change you suggested, like this:
void CMyList::OnBegintrack(NMHDR* pNMHDR, LRESULT* pResult)
{
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
*pResult = TRUE;
}
Perhaps there is something else I'm doing that's preventing your solution from working. But I can't find anything out of the ordinary. I just SubClassDlgItem() and set the extended style to include gridlines and fullrowselect.
Any ideas? Thanks.
Ren.
|
|
|
|
|
If you use classwizard to insert a handler for HDN_BEGINTRACK in the list control, it incorrectly inserts a reflection handler, even though the notification is sent directly to the list control (ie not through the reflection mechanism). That's why the classwizard handler is marked =HDN_BEGINTRACK (= indicates a reflected notification).
You need to replace the line ON_NOTIFY_REFLECT(HDN_ENDTRACK, OnEndtrack) in the message map with ON_NOTIFY(HDN_ENDTRACK, 0, OnEndtrack) . (See the MSDN knowledge base article Q281155)
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|