|
Hi.
I wrote a small drawing SDI aplication for my child, (2 years old). He press a key, and he draw a figure in a Window view. But I want to disable the "Window button" and the "context menu button" of the keyboard, 'cause I won't show the start menu and the context menu while the aplication run, but when I close it I want to enable the buttons again.
How could I do that?.
Thank you and regards from Argentina.
Demian.
Demian.
|
|
|
|
|
One solution is to add a handler for PreTranslateMessage() and handle the virtual code accordingly.
Kuphryn
|
|
|
|
|
Or, you could handle the WM_SYSCOMMAND message and trap the SC_MOUSEMENU and SC_TASKLIST command types. See WM_SYSCOMMAND in the doc for details.
|
|
|
|
|
I will write you some of my code, and if you can tell me please where is an error:
CIPAddressCtrl m_ip_address;
CString set1="127",set2="0",set3="0",set4="1";
int s1,s2,s3,s4;
s1=atoi(set1);
s2=atoi(set2);
s3=atoi(set3);
s4=atoi(set4);
m_ip_address.SetAddress(a1,a2,a3,a4);
it doesn't create, because in debugger I see such picture:
a1 = 127 ''
a2 = 0 ''
a3 = 0 ''
a4 = 1 ''
I don't understand where it take's this ''.
|
|
|
|
|
Uh, you've not declared a1, a2, a3, or a4 anyplace. What are they?
|
|
|
|
|
Can I change the desktop theme through program? Please help me with some ideas...
Thanx in advance
Mahesh
|
|
|
|
|
I don't use themes so I can't verify this but you might be able to use SystemParametersInfo().
|
|
|
|
|
When saving settings the the registry I try and use a key that is the apps name. When the apps name is over 8 characters long the program shortens the key name to 8 characters. (example... for RegistryTest it would shorten it to REGIS~1) I would like it to save to RegistryTest. It works fine when run inside of Visual Studio but does not work when run directly.
Thanks for any help you can give me.
|
|
|
|
|
Do you have a code snippet that shows how you are creating the aforementioned key?
|
|
|
|
|
Yes...
In the registrytest.cpp I have the following line....
SetRegistryKey("TEST"); // sets the Registry location were values will be stored
and in registrytestDlg.cpp I have...
CWinApp *pApp = AfxGetApp();
pApp->WriteProfileString("Values","DBLocation","TEST");
this is a test app I made but the problem happens in every prodject I create that is over 8 characters long in the name.
Coyotedw
|
|
|
|
|
So does this create a key named HKEY_CURRENT_USER\Software\TEST\Values\DBLocation?
In the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem registry key, I'm wondering if you have the PreserveLongNames value set to 0x00000000. I doubt this is the problem as you've no doubt created files with names longer than 8.3 characters in the past. Other than that, you might step into the SetRegistryKey() and WriteProfileString() functions to see what they are doing.
|
|
|
|
|
While run inside the studio enviroment it creates a key named HKEY_CURRENT_USER\Software\TEST\registrytest\Values\DBLocation. When run outside of the studio enviroment it creates the key HKEY_CURRENT_USER\Software\TEST\REGIS~1\Values\DBLocation.
Coyotedw
|
|
|
|
|
I would recommend you use the registry function like RegSetValue(),RegQueryValueEx(), etc...
I have not had any problems using these.
|
|
|
|
|
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();
|
|
|
|