|
yes, we are working on getting them back online, sorry for the inconvenience.
|
|
|
|
|
This is gonna sound like a really stupid question, but I'm new to C++ (been using C#).
If I have a pointer to a char, how can I display the char in a messagebox? (I know to use MessageBoxA but I'm not sure how to make the char into something the MessageBoxA function accepts)
|
|
|
|
|
Omnicoder wrote: If I have a pointer to a char...
Which looks like:
char c;
char *p = &c; Omnicoder wrote: how can I display the char in a messagebox?
You'll need a pointer to an "array" of characters, like:
char *p = "Hello World";
MessageBox(p); MessageBox() expects a pointer to a null-terminated string which is different than a pointer to a character.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
In addition to David's answer, I want to say that you should never call a specific version of a function like MessageBox (so, calling MEssageBoxA or MessageBoxW is wrong). You should always stick to the generic version (without the A or W at the end). Character encoding causes in general a lot of troubles to new programmers, so I strongly suggest this excellent article[^] in order to better understand the concepts. Even if your code compiles now, reading this article can save you a LOT of time for the future (and probably a lot of problems too ).
|
|
|
|
|
i create a popup dialog with mfc, and the dialog entered DoModal function, how can i close the dialog by pressing right-up close button and keep main-software keep going
|
|
|
|
|
Your main application should not stop running if you close a pop-up dialog box that it created. Unless there is some kind of crash happening on the pop-up dialog box clean up.
Suhredayan
|
|
|
|
|
my application only have a dialog with some other win32 windows
|
|
|
|
|
Can you post the code part that is creating the pop up dialog. Just to see how you are creating this pop-up dialog within your application.
Suhredayan
|
|
|
|
|
OK
My CApp:
InitInstance()
{
...
static CDlg dlg;
m_pMainWnd = &dlg;
//int nResponse = dlg.DoModal();
//if (nResponse == IDOK)
// ...
//
dlg.Init();
return TRUE;
}
i create win32 window in dlg.Init() and its CallBackWnd code segment :
case WM_COMMAND:
{
if (IDD_CONTROL_PANEL == wParam)
{
((CDlg*)AfxGetApp()->GetMainWnd())->DoModal();
}
}
|
|
|
|
|
This looks to me like a Dialog application, where the dialog is the main window. So when the dialog closes that is the end of the application. If you want a normal window application that uses dialogs then create a proper framewindow as the main window. If you are using Visual Studio then there are standard framewindow templates to build from.
|
|
|
|
|
Handle the WM_CLOSE message and in the handler, hide the dialog instead of calling DestroyWindow .
This way the dialog is not shown anymore but the program is running.
|
|
|
|
|
i had tried, but it happened exception-error
|
|
|
|
|
Since you said you called DoModal I assume you created a modal dialog box. When this dialog box is closed by clicking the top-right corner's close button, your application should still be running. You don't have to do anything to "keep it running".
Clicking the close button should cause the DoModal to return the value IDCANCEL (and the dialog box being closed) unless you override the handler and do something else.
|
|
|
|
|
maybe i make some wrong, if i closed the dialog box, it'll happen errors
|
|
|
|
|
Try to overwirte the virtual function OnCancel(), and call EndDialog(n) in that.
Or just call EndDialog(n) in OnClose() function.
|
|
|
|
|
i had tried, it all made errors
|
|
|
|
|
thank you for everybody, i used modeless window in last.
|
|
|
|
|
I'm building a small C app. ATM, I'm simply twiddling with a Hello World app because it seems that any app I create will not hit break points.
I opened the project settings and /DEBUG was turned off under the linker settings. I turned that on, rebuilt and located my *.opt file. I attempted to 'debug' again and VS simply skips over the breakpoints. The breakpoint settings indicate that they are set to 'break always' and I *am* running (via F5) the debug version through VS.
I've deleted all breakpoints, clean, rebuilt, adjusted settings and it still acts like it's a Release build.
If I create an MFC app, breakpoints work fine.
Anyone seen this before?
|
|
|
|
|
Like2Byte wrote: I opened the project settings and /DEBUG was turned off under the linker settings.
Are you sure it was set ON in the compiler settings?
|
|
|
|
|
Before I posted originally, I had already changed this setting: "Linker->Debugging->Generate Debug Info" to YES (/DEBUG).
I just now set "C/C++ ->General->Debug Information Format" to Program Database (/Zi). It was set to 'Disabled'.
I've never seen a VS disable all debugging in a new project before and certainly not for a 'DEBUG' build. Do I need new glasses?
Anyway, thanks for your help. I looked there before but must have missed it.
Cheers!
|
|
|
|
|
Like2Byte wrote: I looked there before but must have missed it.
Something I do too often to admit!
|
|
|
|
|
Yeah, I'm going to chock it up to what my teachers told me in high school - "You (as in I) need to slow down."
damn teachers!
|
|
|
|
|
Hello,
I have written one executable in C++ which runs from startup of 'All Users' in user's account. In order to give read and write permissions to the place where this executable reads and writes into a file and creates logs we have a service which gives the particular folder the ACL permissions. Using this concept even restricted user never faces any problem while trying to do any of its designed functionality till XP. But, in some cases starting from VISTA we get the executable visible in task manager but it does not do any thing and also not even makes the log.
I need to find why this happens. If any one knows please throw some light on this
Regards,
Kushagra
|
|
|
|
|
Kushagra Tiwari wrote: I need to find why this happens. If any one knows please throw some light on this
Have you tried running your application under the debugger to see what is happening?
|
|
|
|
|