|
I have noticed that the on-kill-focus is not called for cases where the focus really doesn't leave the control, for example clicking on an icon or perhaps when you press the enter key? What I have done is to force a focus change. The first statement you should have within your method called by the enter click is to set focus somewhere. See if this then calls you on-kill-focus method for the edit box.
If only I had more time!
|
|
|
|
|
We are in the process of taking over a project from HQ team. One part is a configuration tool which is built using MFC. I don't have any experience with MFC (lots with C++) apart from a bit i did at college.
Now I have to pick up this tool. The tool is used to configure a CORBA based server. How should I prepare for this? I don't have much time. Basically I'll get about a week before I must start implementing fresh requirements and fix defects in the tool.
|
|
|
|
|
To get in quick:
1. Do not worry, this is all very easy.
2. Step-debug the application to see how the events are handled, and what triggers what.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
I would work through some articles on this site to get an idea how MFC hangs together, and remember that you can always ask here if you get stuck on something.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I suggest two books and a website:
Book 1 - Teach yourself Visual C++ .NET in 21 days - this will give you a good grasp of implementing some basic features in MFC
Book 2 - Visual C++ .NET Bible - a great, but thorough reference to MFC, it is a behemoth, but nonetheless it has tons of good information. You can skip around to what you need to know
Website - www.functionX.com - this website is awesome for learning MFC. You can do the tutorials on different aspects of MFC and even download an e-book. This tool is indispensible
Oh, one more thing, the MSDN examples. When you click on a help topic, they often have sample MFC projects that show you how to implement specific functions. This should carry you a long way towards becoming well-versed in MFC.
Hope this helps,
BP
|
|
|
|
|
.net is not being used in our company. VS 7.1 is being used. And we put of managed extensions etc. so that code can compile using ACE on solaris and linux also. Will these books still be helpful? Can you suggest some other ones?
Thanks for the refrences. I will use them for my own learning.
|
|
|
|
|
The references are useful if you want to understand how MFC works. Essentially, they will show you what MFC was doing, then you can find similar methods in your libraries that will do the same thing.
I would be happy to suggest other resources, however, I'm not sure about what you're trying to learn.
|
|
|
|
|
Hi,
I have a child class(CChildWnd) that derives from CWnd. This class creates a generic child window dynamically in the CDialog::OnInitDialog(). I'm trying to change the color of the control by capturing the OnCtlColor event from the CChildWnd class. However it never enters. If I add the OnCtrlColor to the CDialog class, then this version works, why doesn't the the Child's class version not work?
Thanks
Anthony
|
|
|
|
|
I believe that this answers your question. From MSDN:
"OnCtlColor - Called if CWnd is the parent of a control when the control is about to be drawn."
|
|
|
|
|
You can alos use WM_ERASEBKGND or
WM_PAINT<code> <br />
<br />
<div class="ForumSig"><font size="2" color="#99ff66"><hr></font><div style="padding: 2px; text-align: left; color: rgba(255, 255, 255, 1); width: 80px"><font size="2" color="#99ff66">WhiteSky<br />
</font></div><hr></div>
|
|
|
|
|
Maybe you can rephrase or clarify your question a little bit. More specific it is, easier for others to help.
Best,
Jun
|
|
|
|
|
Hi all
How to validate the special characters like %,&,which should not be allowed to enter in the edit control in dialog based application.
I need to validate many special characters at a time.how can i validate.
|
|
|
|
|
Either write a filtered edit control (i.e. a control that does not accept certain characters) or filter the string as soon as the user hits "ok" and show him an error, if you find any characters in that field.
With std::strings you could use the .find-family of operations. You could, optionally, .remove any characters that you find unsuitable and then write the result back to the editbox, with a message-box for the user showing what he did wrong.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
I suggest either use a masked edit control, or handle the ON_ENCHANGE notification. If any 'invalid' characters are found in the edit control, disable the OK button.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am using Allan Nielsen's SuperGrid control in a project.
Setting of an option will cause the control to go inactive, but the control does not deactive in the 'standard way' when using EnableWindow(FALSE). The background of the control grey's out like normal but the check boxes and text does not. What I would like to happen when the item is deactivated is the selected item to become deselected and the item to be properly greyed out - not just blanket covered by a grey box as that looks unprofessional.
I have tinkered around with the code and looked at the DrawItem & ODS_INACTIVE but nothing i have done makes any difference. I need some frame of reference but no examples I can find on ownder drawn controls actually go into making them respond to EnableWindow command.
Thanks, G.
|
|
|
|
|
I would like to design an application in C++ that uses a gamepad to control a digital camera. The gamepad will have a USB connection.
Does anyone know where I can find information about how to communicate between the gamepad and the C++ application (How does the program know when a button is pressed for example)?
Thanks,
Kristian
|
|
|
|
|
The API used to read from joysticks and similar is called DirectInput, and googling around might get you some useful leads. Try here or here.
|
|
|
|
|
xkrja wrote: Does anyone know where I can find information about how to communicate between the gamepad and the C++ application
Yes, in the documentation supplied with your gamepad. You should have received a driver with it and some documentation explaining the commands that can be used.
A USB doesn't work like a COM port: you need to open the driver (with CreateFile) and then you can communicate with it by using DeviceIOControl[^] function.
|
|
|
|
|
Hi,
Im using dialog bar. Which has Only one CStatic ctrl.
Now i want to update the text(with current time) in the static ctrl on every second;
How can I achieve this.
Regards,
GAN
|
|
|
|
|
1. Create timer in the beginning of the application:
timer = SetTimer(1, 1000, NULL);
2. Add event ON_WM_TIMER()
void CMainFrame::OnTimer(UINT nIDEvent)
{
if (nIDEvent == 1)
{
// IDC_STAT is an ID of static controll
CStatic* cap = (CStatic*)m_wndDlgBar.GetDlgItem(IDC_STAT);
if (cap)
{
CTime t = CTime::GetCurrentTime();
cap->SetWindowText(t.Format("%d/%m/%y %H:%M:%S"));
}
}
CFrameWnd::OnTimer(nIDEvent);
}
3. At the end of the application don't forget to destroy the timer:
KillTimer(timer);
Nina
|
|
|
|
|
Hi nina
I wud like to make a suggestion (Objcet oriented way i think). it will be better if you write a function inside dialog bar like UpdateHelp(CString &str); and call it from MainFrame.
If u can Dream... U can do it
|
|
|
|
|
I am using this code:
FILE * pFile;<br />
char filename [100];<br />
<br />
pFile = fopen ("\\Settings\\temp.txt" , "rt");<br />
if (pFile == NULL) perror ("Error opening file");<br />
else <br />
{<br />
fgets (filename , 100 , pFile);<br />
fclose (pFile);<br />
}
to get a filename that another part of my program has written. However whatever I put in the text file my program reads 100 Í characters. Now when I open up the text file myself it shows exactly what I want, i.e. not that This is driving me slightly crazy so any help would be great.
P.S. If anyone wants the text file I am quite willing to e-mail it to you.
-- modified at 10:15 Wednesday 23rd August, 2006
|
|
|
|
|
You said another part of your program is writing the file?
Here are a few things to try:
- Initialize your string: char filename[100] = {0};
- Set the file cursor to the beginning explicitly: fseekg(pFile, 0, SEEK_SET);
- Make sure that the file is not currently open by the section of code that is suppose to be writing to it. You may be running into a race condition if you have 2 threads (for example) where thread 1 is writing to the file, but thread 2 is already trying to read from it before the write is complete.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Right, I have made sure that the other program isn't writing to the file. Initializing the char just results in the program returning a blank string. Using fseek doesn't seem to make any difference. Do you think it could be a problem with the format of the file?
|
|
|
|
|
stevelam wrote: Initializing the char just results in the program returning a blank string
That means that fgets isn't reading in anything for some reason. Check its return value to see if it is getting an error.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|