|
Hmmm windows\temp eh? Didn't think of that. I still think APPDATA is probably the best place (thanks AnsHUMAN and Superman.
Tony
|
|
|
|
|
Hi.
I got my own custom button where i am doing all the painting myself. And now there is a problem: default button behavior. You know, like, these fancy regular windows buttons - when you click inside some Edit Box (let it be anywhere on the main app window) - button is drawn with blue shinning color. When you click on another button - that another button becomes default one. When you click inside some other edit box, again - this first button is drawn with a blue shinning color. The thing is : it is not an issue to check the style with:
if( GetStyle() & BS_DEFPUSHBUTTON ) then...
and do some additional drawing. The problem is: how to catch when a user clicked somewhere on another control which is not mine, which is regular windows edit box for example. Or another button which is just windows regular button? How do my button know when to draw some additional stuff to indicate it is a default button?
Thanks
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
|
i cannot see how this should solve my problem.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
|
It handles. But i need to catch somehow messages from other controls.
Currently i am handling WM_MOUSEACTIVATE on a dialog window (this msg is posted when non-focused control gets focus, so basically when you click on any control on a dialog window , this dialog window gets this message) and then posting some dummy message to all child controls to make my controls redraw them selfs. But. There is one BUT. This message is posted before last control loses focus or something like that, anyways, only after second message my controls redraw them selfs correctly, so its like, "there is one click delay" - unacceptable in my case So there should be some better way i dont know about
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
You need to several things:
1. Override CWnd::OnGetDlgCode[^] and specify that your control accepts becoming a default push button (DLGC_DEFPUSHBUTTON ).
2. Handle the BM_SETSTYLE[^] message in your button class, so that you are informed when windows set and removes the BS_DEFPUSHBUTTON style for your button and paint the button accordingly.
0100000101101110011001000111001011101001
|
|
|
|
|
Thank you so much!!
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Glad I could help.
0100000101101110011001000111001011101001
|
|
|
|
|
I am trying to use registry to store some common application data.
Here is my test code
SetRegistryKey(_T("*CCC*"));
{
CString strSection = "1234";
CString strStringItem = "My String Item";
CString strIntItem = "My Int Item";
CWinApp* pApp = AfxGetApp();
pApp->WriteProfileString(strSection, strStringItem, "test");
CString strValue;
strValue = pApp->GetProfileString(strSection, strStringItem);
ASSERT(strValue == "test");
pApp->WriteProfileInt(strSection, strIntItem, 1234);
int nValue;
nValue = pApp->GetProfileInt(strSection, strIntItem, 0);
ASSERT(nValue == 1234);
}
The "problem" is - I cannot see the *CCC* in the registry until the WriteProfileString is executed and application name .ini file is build in c:\windows directory.
Even then the GetProfileString reads the data from ini file and not the registry.
And in registry I have a application name key added.
How did it get there ?
I found lots of registry wrappers here , but I need just basic API explanations, not a wrapper class.
Ideally I do not want to build ini file, so how do I do that?
I need a better description , than MSDN, for SetRegistryKey.
I do not get MSDN explanations about working in either ini or registry.
Sample code to write / read to / from registry without building ini file would be nice ( in VC++ not VB ) .
Any constructive help will be as always appreciated.
Thanks Vaclav
|
|
|
|
|
Vaclav_Sal wrote: The "problem" is - I cannot see the *CCC* in the registry until the WriteProfileString is executed and application name .ini file is build in c:\windows directory.
Do you see anything about your app in the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping key?
Vaclav_Sal wrote: And in registry I have a application name key added.
Do you see this in the HKCU\Software\*CCC* key?
Vaclav_Sal wrote: I found lots of registry wrappers here , but I need just basic API explanations, not a wrapper class.
CWinApp is a wrapper class.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
David,
thanks for your help.
It looks like SetRegistryKey(_T(strSection));
works fine ( I can read the value in regedt32 ) after my app has been run once, but not until than.
So if I wamt to check for correct registry entries and if not there write them using SetRegistryKey I cannot read it immediately back in InitInstance, but somewhere else should work OK.
I did read one of the registry articles here to find out that registry
creates stuff if you check for it and it is not there.
I'll do some more reading to find out more abut this. Maybe this is where the application is being inserted in, since I specify only the section.
I did check the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping for my app and did not find anything there.
I am not that concern about getting the app into the registry but sure would like to know where is it coming from. I guess I could scan for the string and delete it to see when it goes away, if it does.
|
|
|
|
|
Vaclav_Sal wrote: I found lots of registry wrappers here , but I need just basic API explanations, not a wrapper class.
Despite your following comment I always find that MSDN[^] is the best place to look.
|
|
|
|
|
Hello
I want to ask information via keyboard the user. I did a dialog with edit control, this dialog let me to ask the name of the file when the user will kept information.
I made this, but not run
Code:
void CDlgResultados::OnBnClickedButton1()
{
CDlgSaveLoad dlgSL1;
if(dlgSL1.DoModal()==IDOK)
{
dlgSL1.GetDlgItemText(IDC_EDIT1, nombre);
}
SaveToFile();
}
App is in mfc.
The error appear in dlgSL1.GetDlgItemText(IDC_EDIT1, nombre);
|
|
|
|
|
(I will only give partial answer, just to get you going... look for tutorials/sample/example for more complete code and/or documentation)
You cannot access dialog control before a DoModal (the controls are not created yet) or after a DoModal (the control were destroyed).
In your dlgSL1 dialog code, add a CString variable and "attach" it to the CEdit (IDC_EDIT1) with DDX_Control with something like:
DDX_Control(pDX, IDC_EDIT1, m_YouStringVariable);
This can be done manually or with the wizard or the properies (I think); when that is working properly, you can set/get the variable from the parent dialog (in your case: CDlgResultados::OnBnClickedButton1)
if(dlgSL1.DoModal()==IDOK)
{
nombre= dlgSL1.m_YourStringVariable;
}
Another way is to override the CDialog::OnOK in the CDlgSaveLoad class and in there, you can get the string from the CEdit and put it in an intermediate variable:
void CDlgSaveLoad::OnOK()
{
m_YourEdit.GetWindowText(m_YourStringVariable);
CDialog::OnOK();
}
and the code in CDlgResultados::OnBnClickedButton1 will be similar as above.
Max.
Watched code never compiles.
|
|
|
|
|
|
Thank you very much.
+ 10 for the answer.
Here is the answer :
void CDlgSaveLoad::OnBnClickedOk()
{
CDialogEx::OnOK();
m_Edit.GetWindowText(m_strData);
}
void CDlgResultados::OnBnClickedButton1()
{
CDlgSaveLoad mDlg;
if ( mDlg.DoModal() == IDOK )
{
nombre= mDlg.getData();
}
SaveToFile();
}
|
|
|
|
|
Swap the two lines in OnBnClickedOk .
and I assume that
nombre= mDlg.getData();
will return m_strData ?
Watched code never compiles.
|
|
|
|
|
Yes, I forgot write here the method :
public:
CString getData() const { return m_strData; }
|
|
|
|
|
I'm sorry, I have another question.
When I show something in Edit control, it appear selected in hightlight blue, how can I modify it??
I'd like that only appear the text but not hightlight
|
|
|
|
|
antonio343 wrote: When I show something in Edit control, it appear selected in hightlight blue, how can I modify it??
have a look at CEdit::SetSel[^]
M.
Watched code never compiles.
|
|
|
|
|
Ok, but I didn't call this function in my code, and the text appear selected blue when I show the text.
I don't want that the text appear selected
I use to show and get the text GetDlgItemText/SetDlgItemText
Could be this the problem?
|
|
|
|
|
I think that the problen is setfocus() I call this function an it select all the text. I need that the text will be showed without higlight
|
|
|
|
|
Hello Friends
we are creating A desktop based application.And mine application is based on other 3rd application Engine or Enviorement which is having their own Activation code.
So,installation is like that first we will install 3rd application with their activation code.Now,i want to install mine application that will secure 3rd application activation also and also make sure that mine desktop application will be used only on one machine.
I want to secure 3rd application activation because If somehow I make secure mine application and then mine application gets corrupt or expire after trial then that 3rd application will remain on user system.So,I want to secure both through some user Input Activation code or through some other way.
Any Ideas??
Regards
Yogesh
|
|
|
|
|
This is the C/C++/MFC forum.
"Real men drive manual transmission" - Rajesh.
|
|
|
|