|
This is going to sound like a stupid question, but I can't find anything on how to do it. I have a text editor MDI that calls up a dialog box. I have the information saved as a CString in the dialog box, but now how do I get it from there and displayed in my document?
I've looked at the MSDN CD, and also this site, but I can't seem to find a step by step tutorial on how to do it. Can anyone help me to do this simple task, or at least point me in the right direction to find out?
Thanks
Matt Fenwick
|
|
|
|
|
I am just teaching myself MFC so I hope I don't steer you in the wrong direction.
Here is a tutorial I did tried this weekend. It should help. Note, there are a few errors but you should be able to get through it.
http://www.codeproject.com/dialog/dialogapptute2.asp
The tutorial takes data from a various controls and puts it in a list box and then to a dialog box, but the principle should be the same.
You can use the class wizard to make a member variable (I think you will use a category of "control") to hold the data you want moved to the document.
When you come to a fork in the road, take it! Y. Berra
|
|
|
|
|
Well, if your dialog is modal (i.e. you launch it with DoModal ,) things are simple. You already mapped the string to some member variable of the dialog (let's say it's called m_str .) Then, after DoModal , the value is just there for you to use:
void CYourView::OnSomeParticularEvent()
{
CYourDlg dlg;
if(dlg.DoModal()==IDOK){
}
} I hope I made myself clear enough. Good luck with your project.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hi
i want to ignore this event in my application. is there any way out.
|
|
|
|
|
Use the SystemParametersInfo function's
undocumented SPI_SETSCREENSAVERRUNNING
UINT _Junk;
// turn off ctl-alt-del
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING,1,&_Junk,0);
// ... do stuff? like what?
// turn on ctl-alt-del
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING,0,&_Junk,0);
|
|
|
|
|
I created a console app supporting MFC to create a small IRC bot. However I can't get my CSocket-derived class to work properly. The AfxSocketInit() call is successful, and so is CMySocket::Create() and CMySocket::Connect(). Using classwizard I overloaded the OnRecieve member to let me know when there is something to recieve. I've done all this in a regular Win32 MFC app before, and it worked as it should. In this console app however it (CMySocket::OnRecieve()) just doesn't get called. I know there is data to recieve because when I call it myself there is.
I'm really stuck here...
Sprudling
|
|
|
|
|
If I recall correctly from my CSocket days (years ago), don't you need a window to use CSocket ?. If this is true, then a console application won't work.
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
I can't see how it needs a window? The class basicly works, and I can use it to send and recieve perfectly, but the OnEvent()-functions just doesn't get called by the MFC framework. Do I need a message loop or anything to make it do so?
If this isn't possible, how can I check if there is data ready to be recieved, without halting the program if there isn't any?
Sprudling
|
|
|
|
|
|
You do need a window to receive event notifications like OnReceive. Network events are processed with the same mechanism used to process windows messages. So u need a window to receive those notifications. A console app has no connection with windows.
|
|
|
|
|
How can I make a dialogbox as a single instance. So multiple copies cannot get executed.
Thanks
|
|
|
|
|
You can use the class: CMutex
A Mutex it's a kernel object which can be accessed from different process.
Basically on the first run of your application check for a named mutex, if it doesn't exists, create it, if exists exit your program.
Here's a piece of help from MSDN:
"An object of class CMutex represents a "mutex" — a synchronization object that allows one thread mutually exclusive access to a resource. Mutexes are useful when only one thread at a time can be allowed to modify data or some other controlled resource. For example, adding nodes to a linked list is a process that should only be allowed by one thread at a time. By using a CMutex object to control the linked list, only one thread at a time can gain access to the list."
I don't have an example at hand, sorry.
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
This is code I use in my applications to solve this:
BOOL MyAppClass::InitInstance(void)
{
if (IsAppAlreadyRunning() == TRUE)
{
return (FALSE);
}
...
return (TRUE);
}
boolean MyAppClass::IsAppAlreadyRunning(void)
{
if (OpenMutex(MUTEX_ALL_ACCESS, FALSE, UNIQUE_APPLICATION_MUTEX_STRING) != NULL)
{
AfxMessageBox(_TEXT("Error! Application is already running, cannot start another instance."), MB_ICONEXCLAMATION);
return (TRUE);
}
CreateMutex(NULL, FALSE, UNIQUE_APPLICATION_MUTEX_STRING);
return (FALSE);
}
: Dean 'Karnatos' Michaud
|
|
|
|
|
http://www.codeproject.com/cpp/avoidmultinstance.asp
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
In Your Dialogs InitInstance()
Add The Code
CreateMutex(NULL,FALSE,"Single");//last is the name u like
if(GetLastError()==ERROR_ALREADY_EXISTS)
{
//Thre is an instance exists.
//return from here
}
Renjith-The CPian.
|
|
|
|
|
I have a treeview control that was created with the property TVS_CHECKBOXES. When I insert a HTREEITEM I want to be able to specify whether it is checked or not. I am insterting the item like this.
HTREEITEM parent = m_treeView.InsertItem("root",TVI_ROOT, TVI_LAST);
any help will be appreciated.
Thanks,
Bill
|
|
|
|
|
I was thinking that SetItemState would do it but I am not sure what state to set.
Bill
|
|
|
|
|
try this:
m_treeItem.SetCheck( parent, TRUE );
-Raffi
|
|
|
|
|
I believe the following will work:
If m_treeView is a View, you need to get the control
CTreeCtrl & theCtrl = m_treeView.GetTreeCtrl() (This is from memory, so the syntax and spelling may be off a bit, but it's very close.)
Then use:
theCtrl.SetCheck(hParent, TRUE);
HTH
Ron Brunton (I haven't registered yet)
rbrunton@accesswave.ca
|
|
|
|
|
How to manually select entry in the taskbar ?
|
|
|
|
|
This is quite easy:
use ITaskbarList::ActivateTab for this purpose.
Try this:
ITaskbarList *pDisp = NULL;
CoCreateInstance( CLSID_TaskbarList, NULL, CLSCTX_SERVER, IID_ITaskbarList, (LPVOID *) &pDisp );
...
pDisp->ActivateTab(hWnd);
pDisp->Release();
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
100x thx
NodeX
|
|
|
|
|
I would like to implement a way to prevent a Dialogbox in MFC from being loaded on startup when it fails a check of some sort.
Thanks
|
|
|
|
|
In OnInitDialog check it and if it failed use PostMessage(WM_CLOSE)
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I hate to write this for a second time but I am still having trouble.
Hello All, thanks for reading this and for any help you may provide. I am having a problem, I used the "Building Office 2K Addins" article as a guide and I am trying to automate MS Word but I keep getting a compiler error. The error is:
StdAfx.obj : fatal error LNK1179: invalid or corrupt file: duplicate comdat "_IID_CanvasShapes"
I cannot figure out why I keep getting this link error. I am not sure what is causing this. Does any have any idea that may work, it works in the article but not for me. I have included a lot of the code, if anyone needs to see more, just let me know. I am in desperate need and am clueless!!!!
-----------------------------------------------------------------------------------
Instead of importing Outlook, I am trying to import Word in the stdafx.h:
#import "C:\Program Files\Common Files\Microsoft Shared\Office10\mso.dll" rename_namespace("Office") named_guids
using namespace Office;
#import "C:\Program Files\Microsoft Office\Office10\MSWORD.olb" rename("ExitWindows", "WordExitWindows"), named_guids, raw_interfaces_only
using namespace Word;
-----------------------------------------------------------------------------------
My stdafx.cpp looks like this:
#include "stdafx.h"
#ifdef _ATL_STATIC_REGISTRY
#include <statreg.h>
#include <statreg.cpp>
#endif
#include <atlimpl.cpp>
Why would I be getting error. I cannot get around it! PLEASE HELP!!!!
|
|
|
|