|
Thanks, Pavel pal!
Your tools are very helpful!
Cheers,
George
|
|
|
|
|
|
Hey guys,
I wanted to knwo if someone coudl show me hwo to pass variables between 2 dialog window classes. I am writing a program that has 2 dialog windows. I have the user enter the variables in one class, I'd like to display the result in another dialog window(some mathematical stuff). Basically I need to access the variables I have from MyDlg1 class in MyDlg2 class.
Could someone please show me how this is done?
Thanks,
NickOne
|
|
|
|
|
I think an easy way of doing this would be to have pointers to the dialog window.
After creating the 2 dialog windows (d1 & d2) in your main window, you can call a function in d1, passing it a pointer to d2.
After the computation is performed in d1, you can call the display function of the 2nd dialog box using the pointer to d2.
May be you can go in for the sophisticated "callbacks" if necessary.
HTH.
Logic is a systematic method of coming to the wrong conclusion with
confidence.
|
|
|
|
|
Hi.
I often use the use of typedef and tag used global struct in MFC. For example, worker threaders are often declared using a global struct.
-----
typedef struct tagWORKERTHREAD
{
...
} WORKERTHREAD;
-----
I would like to know what are the purpose of tag and typedef in a case like the example above. Why not use this declaration?
-----
struct WORKERTHREAD
{
...
};
-----
Thanks,
Kuphryn
|
|
|
|
|
In short, the first declaration is C and the second is C++. Actually you can use the second form of declaration in C, but then you must repeat the struct keyword in every definition using the type.
|
|
|
|
|
|
I'm having trouble figuring out how to save data to a disk in a MFC dialog app project. Normally when I do this, I'm using the SDI or MDI framework which does all serialization and file handling and all I do is make my data serialize itself when the framework requests it.
Unfortunatly dialog apps aren't as user friendly for me at least when it comes to this. Most of the stuff I've been able to find deal with SDI or MDI. If anyone can point to a resource that will allow me to do this I would appreciate it.
Thanks in advance friends.
|
|
|
|
|
serialization is pretty much up to you, when you're outside the Doc/View world. but, it's pretty easy to do. you can create a CFile object for the data, attach a CArchive object to it, then use the same old "<<" operations to write your data.
you'll have to provide your own file open dialogs, and you'll have to track the "modified" flag yourself, too. but that's all easy.
-c
Aiei i ea eio aoa i e eio e aigoa
|
|
|
|
|
Chris Losinger wrote:
you can create a CFile object for the data, attach a CArchive object to it, then use the same old "<<" operations to write your data.
Do you know of anyplace that has demos of this? I checked msdn, but it is only the Doc/view stuff.
|
|
|
|
|
here's something i use for one of my apps:
BOOL CMapFile::Write(const char *csFileName)
{
CFile theFile;
try
{
if (!theFile.Open(csFileName, CFile::modeWrite | CFile::modeCreate))
{
return FALSE;
}
}
catch (CException *e)
{
e->ReportError();
e->Delete();
return FALSE;
}
BOOL bOK = TRUE;
CArchive archive(&theFile, CArchive::store);
try
{
archive << m_csVersion;
m_data.Serialize(archive);
archive.Close();
}
catch (CException *e)
{
e->ReportError();
e->Delete();
bOK= FALSE;
}
catch (...)
{
bOK= FALSE;
}
theFile.Close();
return bOK;
}
inside the 2nd try/catch, i'm doing your standard archive stuff. everything around it is setup and cleanup. reading is almost identical.
-c
Aiei i ea eio aoa i e eio e aigoa
|
|
|
|
|
|
Is there any way to know the session id of a given process ?
thanx
|
|
|
|
|
the function CDC::LPtoDP
logical unit is used in case of a view. But, i don't know what the meaning of physical unit is.
for ex: LPtoDP(CPoint(0, -850)) returns the constant result (0, 540) when using MM_LOENGLISH. So, what is the screen coordinate?
there are 3 levels of coordinates: logical, physical, "?"??
thank you in advance.
|
|
|
|
|
The device points are determined by the physical size and resolution of the display device (which can be the monitor or the printer, for instance). The logical points are measured in the scaled units you define yourself by means of the mapping mode and calls to SetWindowExt/SetViewportExt (and related functions, se MSDN).
Do not confuse with client/screen coordinates: Client coordinates are relative to the client area of your window, screen coordinates are relative to the screen (and not your window).
In your example, LPtoDP will yield the same result until you change the mapping mode or the scaling.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
is there any difference between minimize and switch off between applications'windows?
for example, a document/view application has an extra dialog box loaded in the CMainFrame::OnCreate(). it is an modeless. i make it the top-level window. i use WM_ACTIVATEAPP to force the dialog to hide on minimizing the main window. When debugging, i realize that there are 2 time at which the OnActivateApp is called. WHy?
if the dialog is hidden when being minimized, it will be still hidden (showwindow(SW_HIDE)) when being maximized. BUT, there are some cases in which it is shown!!!! despite showwindow(SW_HIDE) statement. Can you explain it for me?
thank you in advance
|
|
|
|
|
I have an MFC program (view are derived from CFormView) with some validations done in the OnKillFocus() event handlers for each control on the form. If an error is detected, I display a MessageBox(). When someone hits the Ok button on the MessageBox(), the OnKillFocus() event is repeated again! and Again. and Again. until a stack overflow occurs. The only way I can figure out how to prevent this recursive thing is to have a static bool at the top of the function and use it something like shown below. Anyone have a better method of dealing with this problem?
void MyForm::OnKillFocusLastName()
{
static bool bInside = false;
if( bInside == false)
{
bInside = true;
// blabla
if(m_ctrlLastName.GetWindowTextLength() == 0)
{
MessageBox("Last name cannot be empty","Error",MB_OK | MB_ICONSTOP | MB_TOPMOST);
m_ctrlLastName.SetFocus();
}
bInside = false;
}
}
|
|
|
|
|
You could use PostMessage (not SendMessage) with some (WM_APP + n) identifier. The message would travel through message queue. EN_KILLFOCUS processing would be completed before executing handler for posted message.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Hello,
I'm trying to sort a list of file by name with IShellFolder::CompareIDs. I noticed that the order is not exactly like Windows Explorer. For example, Windows Explorer list "-!!!abc.jpg" first but CompareIDs put "!a.jpg" first. Any idea?
Thanks,
Hiusing
|
|
|
|
|
Hi,
I have a really tough problem relating to MFC and DLL. I have developed a MFC Dll that displays a dialog when it is called by a MFC MDI application. What I did was that first I dynamically created a button on the SDI toolbar by passing the toolbar pointer to the Dll. Then I clicked on the button and a modeless dialog poped up. The modeless dialog contains a 'CMonthCalCtrl' calendar control, an 'insert' button, and a 'cancel' button. When I clicked on the 'insert' button, the Dll should insert the selected date into an already opened MDI edit view. However, I have no idea how to bridge the gap between the MDI view and the Dll (i.e. I do not know how to pass back the date to the view). I have tried to search for related resource on the net but gained no clue and I need the solution desperately.
You have any neat solution??
Thanks in advance.
leonwoo
|
|
|
|
|
Pass in whatever function you call from the DLL a reference to a variable. In the DLL, assign whatever you want to that variable, which in this case is a date.
Kuphryn
|
|
|
|
|
Thanks for the prompt reply. Another question is how do I detect button click from the dialog? I need to insert the date into the view whenever i click on the 'insert' button. The MDI application somehow has to detect the button click and then return the reference variable.
thanks.
leonwoo
|
|
|
|
|
I would pass the handle of the view to the dialog and then send a private message to the view from the dialog. In the LPARAM I would pass the relevant information. If your data does not fit into the four bytes I would use an automatic structure to hold the data and call SendMessage. Do not allocate the struct with new in the dll and delete it with delete in the main app, that will corrupt the heaps.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I am new to using the appwizard with the "Windows Explorer" option for how it looks.
I have set up my tree view on the left hand side and that is working fine. Including adding and removing branches of it.
The issue I am having now is getting the right hand List to change what it displays according to what is selected in the tree view.
Can anyone out there point me in the right direction. Or show me a relevant example.
It is very much appreciated.
|
|
|
|
|
You need to add a handler to the CLeftView Class (the one controlling the tree list)
void CLeftView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult);
This gets called whenever the selected item in the tree changes...
Then use "CDocument::UpdateAllViews" to let the other views (the right hand) know about the change.
/sad joke alert.../
Its just a matter of letting the right hand know what the left hand is doing...
Blade[DMS]
|
|
|
|