Click here to Skip to main content
15,881,859 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Does CString;;GetBufferSetLength Set/Allocate the CString Buffer Pin
Jochen Arndt21-Jul-17 3:35
professionalJochen Arndt21-Jul-17 3:35 
Question《programming game AI by example》 Pin
bestbear19-Jul-17 20:11
bestbear19-Jul-17 20:11 
AnswerRe: 《programming game AI by example》 Pin
leon de boer19-Jul-17 20:51
leon de boer19-Jul-17 20:51 
GeneralRe: 《programming game AI by example》 Pin
bestbear21-Jul-17 2:12
bestbear21-Jul-17 2:12 
QuestionHelp with Heap Corruption "Critical error detected c0000374" Pin
ForNow19-Jul-17 13:47
ForNow19-Jul-17 13:47 
AnswerRe: Help with Heap Corruption "Critical error detected c0000374" Pin
leon de boer19-Jul-17 20:16
leon de boer19-Jul-17 20:16 
GeneralRe: Help with Heap Corruption "Critical error detected c0000374" Pin
ForNow19-Jul-17 21:42
ForNow19-Jul-17 21:42 
GeneralRe: Help with Heap Corruption "Critical error detected c0000374" Pin
leon de boer19-Jul-17 22:05
leon de boer19-Jul-17 22:05 
This is where MFC obfuscating what is happening is annoying. You are building the dialog currently try not setting the modal flag and don't insert it into the desktop and tell me what happens Smile | :) .

You can make a dialog at any point in the lifecycle of your program, later on you can insert it into the desktop and make it visible and modal because that is how these things are designed to work.

The RichEdit control will happily take text, new or added or anything else you want via the message system. You can also talk it by it's control ID the sample below uses the handle.
CHARRANGE cr;
cr.cpMin = -1;
cr.cpMax = -1;
SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&cr);
SendMessage(hwnd, EM_REPLACESEL, 0, (LPARAM)some_new_string);
That is how windows is designed to work. The best bit if you don't use the HasString flag you can just send the pointer in to the text which saves copying and moving the text.

If you have a dialog coming up a lot you are expected to do it that way or via the dialog template system so you don't fragment the hell out of the memory. Common dialogs works that way you know FileOpen, FileSave etc.
CreateDialogIndirect function (Windows)[^]
Creates a modeless dialog box from a dialog box template in memory

All you have to do is insert your changes to the text etc via the message system using the control ID's, put it into the desktop or your app and then set the dialog modal and viola it looks just like what you are doing now.

I don't have a problem creating the odd dialog on the fly but if it comes up a lot try and at least use windows the way it was intended.

The debug thing uses a similar trick but into a multiline text window. They change the malloc stub to post the text messages to the multiline edit window.

I think that this is the sample Microsoft uses to show how to do it in MFC. Not much of a sample and doesn't explain why you do it. The template sample does however contain a multiline edit element to show you they are not anything special.
VCSamples/VC2010Samples/MFC/general/dlgtempl at master · Microsoft/VCSamples · GitHub[^]
In vino veritas


modified 20-Jul-17 10:48am.

GeneralRe: Help with Heap Corruption "Critical error detected c0000374" Pin
ForNow20-Jul-17 6:43
ForNow20-Jul-17 6:43 
GeneralRe: Help with Heap Corruption "Critical error detected c0000374" Pin
leon de boer20-Jul-17 17:29
leon de boer20-Jul-17 17:29 
GeneralRe: Help with Heap Corruption "Critical error detected c0000374" Pin
ForNow21-Jul-17 2:47
ForNow21-Jul-17 2:47 
GeneralRe: Help with Heap Corruption "Critical error detected c0000374" Pin
leon de boer21-Jul-17 3:35
leon de boer21-Jul-17 3:35 
AnswerRe: Help with Heap Corruption "Critical error detected c0000374" Pin
Jochen Arndt19-Jul-17 21:36
professionalJochen Arndt19-Jul-17 21:36 
GeneralCards.dll Pin
Member 1171866719-Jul-17 1:40
Member 1171866719-Jul-17 1:40 
AnswerRe: Cards.dll Pin
Jochen Arndt19-Jul-17 3:29
professionalJochen Arndt19-Jul-17 3:29 
GeneralRe: Cards.dll Pin
Richard MacCutchan19-Jul-17 4:59
mveRichard MacCutchan19-Jul-17 4:59 
GeneralRe: Cards.dll Pin
leon de boer19-Jul-17 5:54
leon de boer19-Jul-17 5:54 
GeneralRe: Cards.dll Pin
Richard MacCutchan19-Jul-17 6:58
mveRichard MacCutchan19-Jul-17 6:58 
QuestionCompiler generated code Pin
ForNow13-Jul-17 14:43
ForNow13-Jul-17 14:43 
AnswerRe: Compiler generated code Pin
leon de boer13-Jul-17 16:43
leon de boer13-Jul-17 16:43 
GeneralRe: Compiler generated code Pin
jschell15-Jul-17 7:34
jschell15-Jul-17 7:34 
AnswerRe: Compiler generated code Pin
Peter_in_278013-Jul-17 16:44
professionalPeter_in_278013-Jul-17 16:44 
QuestionInterprocess communication in C without pipes or disk Pin
Chris Maunder12-Jul-17 13:14
cofounderChris Maunder12-Jul-17 13:14 
AnswerRe: Interprocess communication in C without pipes or disk Pin
Espen Harlinn12-Jul-17 14:03
professionalEspen Harlinn12-Jul-17 14:03 
GeneralRe: Interprocess communication in C without pipes or disk Pin
leon de boer12-Jul-17 18:49
leon de boer12-Jul-17 18:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.