|
The registry will not shorten the name of the key. My guess is that your app is using the actual [base] name of the executable and it's picking up the short name. (Since a user could rename the app, this is a bad idea.)
|
|
|
|
|
Hi !
I have a SDI app, where I have defined an accelerator for the F3 key.
In this app, I have a dialog window opened all the time, and i need the accelerator to be effective, even when the focus is on the dialog.
I have tried to handle the VF_KEY (heu .. i am not sure about the name .. anyway, it is the "key message") in my dialog, and i then send post a message to the mainframe. Is there a better way to do it (because this one does not always work properly, sometimes the function is called twice, sometimes it is not handled by the overrided key function in the dialog).
The function is supposed to toggle the dialog (enabling or disabling its being showed).
~RaGE();
|
|
|
|
|
you should be watch what you send after you handle the message.
the first time you hook into the message, handle it. then "delete" it.
so that no other window handle the message again.
|
|
|
|
|
i am assuming that the dialog is modeless ?
just to give you somewhere to start looking CWinApp::Run()
and maybe IsDialogMessage()
TranslateMessage produces WM_CHAR messages only for keys that are mapped to ASCII characters by the keyboard driver.
If applications process virtual-key messages for some other purpose, they should not call TranslateMessage. For instance, an application should not call TranslateMessage if the TranslateAccelerator function returns a nonzero value.
|
|
|
|
|
Hi.
I have a problem which relates to custom control. let me try to describe it:
description of dll1:
holds CMyPropertySheet and CMyPropertyPage (customized deriviations from MFC)
holds CPropertySheetMediator which is a singleton and is incharg of creating the CPropertySheet and adding the property pages to it.
description of dll2:
hold CGenPropertyPage which derives from CMyPropertyPage and holds a member of MyCustomControl which is the old thing this property page displays
description of dll3:
this is (like the first two) mfc extension dll which is dynamiclly linked to mfc (not statically) and is a dynamic library (not static .lib file)
the custom control calls RegisterClass in it's constructor to register it's window class.
description of application:
the application calls a method of CPropertySheetMediator to create an instance of CMyPropertySheet which contains only one page, CGenPropertyPage
then the application calls DoModal on that propertysheet instance it get's back from the mediator.
for some odd reason, DoModal fails (tracing into mfc code reveals that do WM_INITDIALOG message is sent to the propertysheet but is not received by it)
At the begining i thought it was a resources problem, but it isn't. If i remove the custom control place holder from CGenPropertyPage, the sheet is displayed and runs without a problem, so i figured it has something to do with the window class registration.
ofcourse i should mention that if CGenPropertyPage resides in the application and not in dll2 everything works just fine.
Any ideas ?
Thanks.
|
|
|
|
|
My guess is that it can load the template fine when the propety sheet is being created, but it is failing to load the custom control info when it creating the CPropertyPage object and initialising the controls.
It may be necessary for you to make sure that the correct resources are selected at the time the OnInitDialog()/OnInitialUpdate() for the CPropertyPage is called. So you would need to do:
OnInitDialog/OnInitialUpdtate()
{
HINSTANCE old = AfxGetResourceHandle();
AfxSetRexourceHandle(hInstanceOfDll);
CPropertyPage::OnInitDialog()/OnInitialUpdate();
AfxSetResourceHandle(old);
...
}
This is caused by your DLL being dynamically loaded and not being added to the MFC DLL resource chain.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Thanks, but the problem is that the page's OnInitDialog doesn't get called...
Again, tracing into DoModal code shows that the dialog template (atleast for the sheet) is found and that's it.
Any other idea ?
|
|
|
|
|
Can you post the code from your dynamically loaded DLL for the propertypage class. It could be that when the page gets registered, it oly uses the CPropertyPage base class and not the CYourPage class when the message map entries are getting processed. Also the code which adds the page to the sheet may be useful in understanding the problem as well.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Hi
does any one know how to save a CListCtrl object as a file
i have report style list control, with 3 columns of data
and want to save all of th values as a txt file
any ideas ??
thanks
si
|
|
|
|
|
#include <iostream.h>
fstream Outtxt("myfile.txt",ios::out);
for (int i=0;i<m_List.GetItemCount();i++)
{
for(int j=0;j<NbItemPerColumn;j++)
{
Outtxt<<m_List.GetItemtext(i,j)<<endl;
}
}
Outttxt.close();
~RaGE();
|
|
|
|
|
Hi,
While Im using subForms in my Options Dialog, i want to read out the Controls Data, like text out of a CEdit Ctrl. Normally i would do this with DDX and Classwizard -> with result I have a variable which i can use. But with the use of subForms I have no scope anymore to these subForm Dialog Elements.
Im using the SubFormCollection Class from the Article "Child Dialog (Sub Forms)" from D. Zuppinger. [http://www.codeproject.com/dialog/childdlg.asp]
How can i retrieve the Data out of a Control in a SubForm Dialog to my Main Dialog?!
So maybe somebody out there might have an Answer with a little bit of source would be great.
Thanx to all in this community
Andre
|
|
|
|
|
I do not know the code, so ...
The subforms are simple dialogs, so you must have a class for each dialog where you can put a member variable the one you meant by with result I have a variable .
Then, I assume the subForms class must have a table of handles or pointers on the different dialogs, or something in this way.
So take the index of your dialog, and try something like :
CDialog *pDlg=(CDialog *)m_SubForms.m_Forms.GetAt(Index);
pDlg->m_myEditCtrl // do your stuff.
~RaGE();
|
|
|
|
|
Thanx for your fast reply.
I have tried something like this what you have wrote.
Problem of your Code above is that the compiler will generate an error
cause of CDialog has no member m_myEditCtrl. Now i had the Idea to deriver the CDialog Class with my Dialog Class e.g. mySubFormDlgClass. The Code look something like this
mySubFormDlgClass *pdlg = (mySubFormDlgClass*)m_Forms.GetAt(index);
with this Construction there is no error but an Assert @ runtime! So this is not the way. Another Problem is that if i insert some AFX Messages with Classwizard into my mySubFormDlgClass,set breakpoints in this Event Functions and want to debug - there is no interruption. The Event does not occur.
So only a ShowWindow takes places, no DoModal() function. Maybe there is the Problem. If i do a DoModal the Dialog opens but must be closed if i want to use my MainDialog while the other is open. I will research some time on this. Maybe you have some ideas.
Thanks
Andre
|
|
|
|
|
triggerdie wrote:
cause of CDialog has no member m_myEditCtrl
... Of course your CDialog has no m_myEditCtrl variable !!! I cannot guess your variable names !! This was only an exemple. Sorry for the misunderstanding. I think the articla was just a basis, you have to work on it to get your data retrieved. The easiest way to do this is the one I gave you. So, let's take it again. Change this in the code of SubFormCollection.h :
instead of
protected:
CArray<CDialog*, CDialog*> m_Forms;
put
CArray<CDialog*, CDialog*> m_Forms;
protected:
This will enable you to get at the m_Forms table by setting m_Forms as public.
Now you should have a main dialog, let's say CMainDlg, a CSubFormCollection, and some child dialogs, let's say CChildDlg1 and CChildDlg2 with respectively ressource IDD_SUBFORM1 and IDD_SUBFORM2 (Go in the properties of your dialogs in the ressource editor to set that). Replace these names by your variable names if they are different !!.
First, follow all the steps given in the article, especially step 5 :
CSubFormCollection m_SubForms;
(this in the MainDlg.h file.
and step 6
CRect r;
(GetDlgItem(IDC_SUBFORM_FRAME))->GetWindowRect(&r);
m_SubForms.SetCenterPos(r);
m_SubForms.CreateSubForm(IDD_SUBFORM1,this);
m_SubForms.CreateSubForm(IDD_SUBFORM2,this);
m_SubForms.ShowSubForm();
(this in the CMainDlg::OnInitDlg() file.)
Now you have two subForms, with index 0 and 1.
Then, as an example, place an edit box on the ressource of CChildDialog1, open the class wizard, add a member variable m_myEditCtrl of type CEdit.Close the class wizard.
Add a
m_SubForms.ShowSubForm(0);
in your code (in CMainDlg::OnInitDlg() for instance), to show the first subForm.
You can now retrieve the text entered in the edit box by the user with :
CDialog *pDlg=(CDialog *)m_SubForms.m_Forms.GetAt(0);
CString str=pDlg->m_myEditCtrl.GetWindowText();
Ouf ... mail me directly your code if you do not get it to run, i'll be glad to help you further.
~RaGE();
|
|
|
|
|
OK. So i made a project and tested the article code, and found out it is totally crap. it is unfinished, sometimes even wrong (under NT, my subFroms were not getting docked in the main dialog) and the Table pointer is not reliable. Drop it !
As for your code sample, it was because you have cast the pointer on a CDialog, and not on your CDialog name (dlgOpt_ServerPort).
~RaGE();
|
|
|
|
|
two ways.
first.
on the close routine of the options dialog. you send the text you wand to you parent and save it there.
second.
(i dont take a look on the childdlg.asp) if you use a normal dlg. with DoModal. then create your dialog on the stack not on the heap. mydialog* blub = new mydialog; blub->DoModal(); CString myvar = blub->mycstringvar; delete blub;
|
|
|
|
|
I don't know what you mean with SubForm, but if the subform is a dialog placed as a control inside a parent dialog, you can use member functions in the child dialog always...
I mean that is better to use member functions to get the values than getting the values directly by calling SubForm.m_CstringInEditCtrl if you use member functions (GETxxx and SETxxx in order to obtain and modify values) you'll always will be able to readapt the returned value or format the sent value as is desired...
then I would do:
1. from the parent dialog/window/... you'll always have access to the childs.
2. Using the previous premise, you'll be able to call members/methods/functions from the class of the child dialog.
3. I would call methods/functions of the subform in order to get/set the desired values and in order to make it safely.
Hope this helps.
NOTE:
Get and set are only prefixes that I use in order to use the hungarian notation and know what the function do before reading its content.
|
|
|
|
|
Hello Joan,
Thanx for your fast reply. Is it possible do change dynamicly from the parentsDialog to the ChildDialog without to destroy the ChildDialog.
I want to change the HIDE and SHOW behaviour of several Child Dialogs.
How can I do this? Without using of DoModal() only with ShowWindow().
Cause if i do a DoModal() i can not make any interaction with my parentDialog while the ChildDialog is open. Wihtout a DoModal and just ShowWindow it does not work. Assert @ runtime. So i dont know how to solve this Problem. I want to use the Std Afx Message Functions of each Child Dialog. Maybe you have an advice.
See you
Andre
|
|
|
|
|
Hi, everyone!
When reading source code of others, I find they often
use int64 to represent 8-bit integers. I have referenced
MSDN and find the comments there are not enough.
Can anyone tell me where can I find reference about this
topic? Another question, can this data type be used on
Non-windows platform, for example, Linux?
Thanks in advance,
George
|
|
|
|
|
The _int64 data type is compiler specific and might not port. However, gcc supports a data type such as LONG LONG.
If you are looking at porting code to other platforms, then anything that must be size specific should be done with typedefs or defines.
Example:
#if defined (WIN32)
typedef _int64 INT64
typedef unsigned _int64 UINT64
#elif define (WHATEVER_LINUX)
typedef long long INT64
typedef unsigned long long UINT64
#endif
Then in your code only use INT64 or UINT64.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thanks, Tim buddy!
George
|
|
|
|
|
First _int64 is Microsofht specific.
Second _int64 represents a 64-bit interger.
If you do a search on MSDN, for _int64, you will find at lease 31 seperate entries. If you search for "microsoft _int64" on google you will find over 200 entries, many of which appear to do with porting. I know of no other sources of information on _int64.
Trust in the code Luke. Yea right!
|
|
|
|
|
Thanks, John buddy!
George
|
|
|
|
|
Hi
I'm inserting all kind of columns in a CListCtrl
with structure LV_COLUMN like this:
ColumnVi = new LV_COLUMN();
CString Title;
ColumnVi->mask = LVCF_TEXT | LVCF_WIDTH;
ColumnVi->fmt = LVCFMT_CENTER;
//Inserting
ColumnVi->cx = 35;
Title = "Nr.";
ColumnVi->pszText = Title.GetBuffer(3); m_PersCtrl.InsertColumn(0,ColumnVi);
//Insert the column into the clistctrl
The width of column i've set to 35, i tested it out and changed the value until it looked good. but the caption can change at some time .. so how can i know how much pixels 1 char. takes or anyone have other ideas to make it more dynamic?
Greetings Jens
|
|
|
|
|
You may combine GetStringWidth and SetColumnWidth of CListCtrl.
rechi
|
|
|
|