|
Do you mean import? One solution is to import the dialog box class in the new project. Export the dialog box template and import it in the new project.
If you meant controlling the dialog box in another program, then you should consider other solutions including file-mapping, namepipe, Winsock, and COM.
Kuphryn
|
|
|
|
|
When I go to the dialog box that I want to export, the context menu can't display Export but only import.
youssef
|
|
|
|
|
i have an MDI application with 2 views .
Initially in the App class I do the following :
CMultiDocTemplate* pDocTemplate;<br />
pDocTemplate = new CMultiDocTemplate(<br />
IDR_MDI2TYPE,<br />
RUNTIME_CLASS(CMDI2Doc),<br />
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CPersonalityGenerator1View));<br />
AddDocTemplate(pDocTemplate);<br />
<br />
<br />
secondTemplate = new CMultiDocTemplate(<br />
IDR_MDI2TYPE,<br />
RUNTIME_CLASS(CMDI2Doc),<br />
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(View1));
// I DO NOT ADD THIS SECOND TEMPLATE
On a New document I do the following :
if (!CDocument::OnNewDocument())<br />
return FALSE;<br />
<br />
CMDI2App *myApp=(CMDI2App *)AfxGetApp();<br />
CMainFrame *mnd= (CMainFrame *)(myApp->m_pMainWnd);<br />
CFrameWnd *allotedFrameWnd;<br />
allotedFrameWnd=myApp->secondTemplate->CreateNewFrame(this,0);<br />
myApp->secondTemplate->InitialUpdateFrame(allotedFrameWnd,this, TRUE);<br />
allotedFrameWnd->SetActiveWindow();<br />
allotedFrameWnd->ShowWindow(SW_HIDE);
I am suppressing this second View by hiding it AND i display the first view . This is what i want initially !
Now I need to activate this view on an On Button Event from the Toolbar
In the active View i am trying to do something as :
<br />
void CFirstView::OnSwitchView()<br />
{<br />
<br />
POSITION pos = this->GetDocument()->GetFirstViewPosition();<br />
<br />
CView *v2 = this->GetDocument()->GetNextView(pos);<br />
<br />
v2->GetActiveWindow();<br />
<br />
v2->GetParentFrame()->ShowWindow(SW_SHOW);<br />
}
I find that the views are not getting switched . I observe no change . Please help
|
|
|
|
|
I'm looking for an explanation of how to detect an idle period within an application and close dialogs and log off the application if the idle period is exceeded.
I have information on how to detect the application idle time by using Paul D.'s IdleUI DLL from Feb. 2000 MSJ, but I'm curious how to find a modal dialog that is currently displayed and close it. Will I have to send a user windows message to the dialog and write a message loop for the dialog to get it?
Any one of a number of modal dialogs in the app can be displayed when the idle time is exceeded and I can't seem to figure out how to notify these dialogs that they should close. Also, will I even get system hook notifications in the main app if a modal dialog is currently displayed?
Thanks...
|
|
|
|
|
Do you have control of the dialog boxes? Call its destroy function, DestroyWindow(), or post a WM_DESTROY message.
Kuphryn
|
|
|
|
|
I have an Application in Vc++ . From this application I want to invoke another Application .
Imagine invoking Notepad to view a file .
How do I do this ?
|
|
|
|
|
_spawn, CreateProcess, WinExec and ShellExecute are all popular methods.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
For a command line:
Use system if you want the command line interpreter to handle it.
Use ShellExecute/ShellExecuteEx if you want the Windows shell to handle it.
Use CreateProcess if you want Windows to handle it.
|
|
|
|
|
I try to write a program to talk to a external device via com port1. I use WriteFile() to send the ascii command: I verified to see that the ASCII command that I send out does go out to the port. I checked the correct configuration for the port(baudrate,stopbit...). But the devide still does not respond. However, the device is responding when I use windows hyperterminal to send the exact ascii command. Does anyone know why?
Does hyperterminal terminate the stream it sends out with a special ascii value that my program doesn't ?
Please help!
Thanks, peter.
|
|
|
|
|
Nope. After setting up the DCB with SetCommState and the timeouts with
SetCommTimeouts, sending out the commands via WriteFile should be enough.
Hook up COM1 to COM2 via a null-modem cable. Connect to COM2 via terminal emulator (Hyperterm or whatever.) and pretend you are the device. Connect your program to COM1 and check out what is being sent.
|
|
|
|
|
Hi, I'm looking for a MFC/Vis C++ example of a rotary dial control. I located one in the CP archives, but thought there were others.
http://www.codeproject.com/miscctrl/rotary.asp
Any help?
Thanks,
Johnny
|
|
|
|
|
you could try this[^]
Error 4711: Signature expired
|
|
|
|
|
I liked this one:
http://www.marvgolden.com/health-safety/relief_bands.htm
-- seriously though, was looking for a quick one that you might know about.
|
|
|
|
|
Thats what I call a "reusable component"
Error 4711: Signature expired
|
|
|
|
|
hi
i am using EnumPrinters() function in my project. this is working fine. in msdn help they given if EnumPrinters() successfully executed it returns nonzero value otherwise zero value. but i am getting zero value for successful working of EnumPrinters(). so which one is right please clarify my doubt
thank you
|
|
|
|
|
Try to catch a CDBException like this:
try
{
}
catch (CDBException* e)
{
AfxMessageBox (e->m_strError);
e->Delete ();
}
It may give you useful information
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Does anyone know what is the preferred what to pass variables to a function ? Assuming the value does not need to change.
For example I was just recently old that
foo( long val ) was preferable to
foo (const long& val )
Isn't the second form more efficient ? I had always thought this, plus the use of "const" clearly marking something as not changing. Any thoughts welcome here
¡El diablo está en mis pantalones! ¡Mire, mire!
|
|
|
|
|
const reference is what is favoured by the 'gurus', like Scott Myers and the like.
in case of a long int, it may make no big difference, but when you have to transfer an object of several hundreds of bytes, things are different.
As for the const, it simply is a good habit, giving the compiler the opportunity to assist you in adhering to your own guidelines.
|
|
|
|
|
The const is important for the optimizer. It allows the caller more freedom to optimize since it knows the callee won't change the value.
However, for small values that can normally be passed on the stack, using a const reference will slow things down. So for ints, longs, etc..., don't use a const reference. Just pass the value normally.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
For built-in types, there is no copy constructor that may cause unwanted side-effects when passing by value. For user defined types, there may be side effects when (if it is even possible to) passing by value which invokes the copy constructor. That's why passing by reference is generally better for user-defined types-- you're just passing the ability to access the same object instead of a copy of the object. (and if you will make no changes, pass a reference to the object as const.)
|
|
|
|
|
Hmmmmm - the copy constructor that you are talking about would be called buggy here.
Either it does its work flawlessly or it is impossible to call (private).
|
|
|
|
|
That is not necessarily true.
A copy constructor can have unwanted side
effects that are not bugs.
Take for example, auto_ptr.
Its copy constructor will pass ownership
to the copy being passed to the function
in question. Upon return, the original
auto_ptr will no longer point to a valid
object, it having been destroyed when the
function's copy of the auto_ptr deleted
the object. This is almost certainly not
what the designer of that function nor its
user would desire.
|
|
|
|
|
Well, std::smart_ptr is something special with its odd, but documented behaviour.
AFAIK is a reference on a std::smart_ptr also doomed: If it goes out of scope the contained ptr gets deleted, even if another reference elsewhere is still there, leading to an error when it goes out of scope.
So I tend to not use std::smart_ptr and use boots shared_ptr, which uses reference counting to show an intuitive behaviour.
For me, the std::smart_ptr behaviour, even if documented, looks like a bug, smells like a bug - must be a bug.
The same would be a class that, well documented, overrides opeator< with "true on less or equal": Allowed but extemely buglike. You can't sort anymore.
|
|
|
|
|
To add to what others have said:
1. Passing by value has the added perk of letting you to change the value of "val" inside your function (just like any other local variable), which may prove convenient.
2. Passing by const reference gives the possibility for the function to actually alter the value of "val" by casting away the constness. I know this is silly since most likely you're the one who's writing the function, but it does add to why its just better to pass native types by value instead of const reference.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
|
|
|
|
|
Hi all.
When not using the "Document/View architecture support" in the step 1 of AppWizard, Must the view of a program be an object whose class is derived from CWnd?
i wanna write a program without "document/view architecture support" and its view is a CView object or a CHtmlView object. i try accept the default value(using the object whose class---CMyView derived from CWnd as the view), and after finishing the wizard, i change the base class of CMyView from CWnd into CHtmlView(include the BEGIN_MESSAGE_MAP macro, IMPLEMENT_DYNCREATE macro), it can run, but it crashes when it close. why?
|
|
|
|