|
Hey guys,
I'm absolutely not a experienced programmer but i have a problem, i will be happy someone can help me.
I have a dialog class CSimulator with a number of timers:
//part of the XXXXX.h file ****************************************************
class CSimulator : public CDialog
{
DECLARE_DYNAMIC(CSimulator)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
...
...
...
public:
virtual BOOL OnInitDialog();
void OnTimer(UINT nIDEvent);
//part of the XXXX.cpp file ****************************************************
IMPLEMENT_DYNAMIC(CSimulator , CDialog)
void CSimulator::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CSimulator, CDialog)
ON_WM_TIMER()
...
...
END_MESSAGE_MAP()
void CSimulator::OnTimer(UINT nIDEvent)
{
...
...
...
CDialog::OnTimer(nIDEvent);
}
When i start the class CSimulator from another class (CWnd) with DoModal() everything is working fine and the function CSimulator::OnTimer(UINT nIDEvent) is called after setting a timer with SetTimer(IDTIMER,50,0);
But when i start the class CSimulator from another class (CWnd) with m_Simulator.Create(IDD_SIMULATION_DIALOG); (m_Simulator is the instance of class CSimulator)
i have a problem. In this situation i don't receive the ON_WM_TIMER message .
Note: At another situation i need the class CSimulator (CDialog) showed in a window, but in this situation i only need the algorithm of the class, only modeless
What i'm doing wrong? I search a lot, but don't see the problem, can anyone help me with a solution?
Thanks, Bart
|
|
|
|
|
You must be doing something wrong with your modeless dialog. This worked for me:
CMyDialog::CMyDialog( CWnd *pParent ) : CDialog( CMyDialog::IDD, pParent )
{
Create(IDD);
}
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
ON_WM_TIMER()
END_MESSAGE_MAP()
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
SetTimer(1234, 50, 0);
return TRUE;
}
void CMyDialog::OnTimer(UINT nIDEvent)
{
TRACE(_T("OnTimer()\n"));
CDialog::OnTimer(nIDEvent);
}
...
CMyDialog *pDlg = new CMyDialog;
pDlg->ShowWindow(SW_SHOWNORMAL);
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
how do you get a websites source code? I need all the links (over 1500) and I will parse the data after I get the code, i am using a dialog based app and have a webbrowser I need to get the info from,
thanks
|
|
|
|
|
Hi,
I understand, you have an application and want to get the HTML-sourcecode and parse them?
Take a look at this:
http://www.codeproject.com/miscctrl/simplebrowserformfc.asp
I think this is off-topic, but ...
To get a website and all links from this site use "Mozilla-FireFox" and the AddOn "downThemAll". Now you need only a "right-mouse-click" and change some options from "downThemAll" and the FireFox will save all website to your harddisk.
Mozilla
downThemAll
|
|
|
|
|
|
I wrote a program that part of it involves closing other windows, but I run into some funny stuff if the window is minimized when I close it. Is there any way I can check to see if a window is minimized before closing it? I have the window handle.
Yesterday is history
Tomorrow's a mystery
Today is a gift
That's why they call it the present.
Danny
|
|
|
|
|
IsIconic Function
The IsIconic function determines whether the specified window is minimized (iconic).
BOOL IsIconic( HWND hWnd<br />
);
|
|
|
|
|
|
you can use CWnd::isIconic() this function. It return non zero it it is minimized, otherwise 0
|
|
|
|
|
When adding a new dialog resource, the OK button is automatically configured so that, when clicked, it will take you off the form and do whatever code you wrote in an if statement:
if(dialog.DoModal() == IDOK){}
I want to add another button, Restore Defaults, that will take me off the form like the OK button and I can make an else if statement such as:
int returned = dialog.DoModal();
if(returned == IDOK){}
else if(returned == ID_RESET_DEFAULTS){}
How do code this?
Danny
|
|
|
|
|
In the handler for this "Restore Defaults" button, simply call EndDialog(ID_RESET_DEFAULTS) .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thanx!!
(The book I was using to learn MFC must not be the greatest)
Danny
|
|
|
|
|
maybe the cheapest ?!
or maybe you failed reading it ;P
anyway, you found the right place for C++ questions though...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
is there an API call to obtain the list of COM ports as listed by Device Manager .
|
|
|
|
|
disclaimer: don't know how well MS supports this in all versions of Windows, so use at your own risk
The list of serial ports can be found in the registry at HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM
You can use RegEnumValue() to enumerate and create the list you need.
|
|
|
|
|
|
Cool
Given its description - The EnumPorts function enumerates the ports that are available for printing on a specified server. I don't think I EVER would have thought to use this to enumerate the serial communication ports.
|
|
|
|
|
Needles to say, not a directly Visual C++ question, but a
weird one, clearly related to intimately Win32 API.
To make a long story short:
- I developed a desktop application, using MFC and having, among other controls a list control.
- During development ant testing, everything looked OK.
- As a must, when the application is installed on a real user machine, it must register itself in "run at startup applications" (Registry locale machine key), and start a dialog, where some data is displayed (loaded in the list control)
And now come the WEIRD thing: on one of the machines, used for testing, the application failed to instantiate... because the List control was not instantiate. In other words, the application UI started before common controls being available!!! Is such a thing possible???
Did anybody encounter such situation before? Does anybody heard about such a weird problem in his experience?? Did exist a remedy?? Of course, I did not take in consideration a hack, like a "sleep" in my application startup... what make me worry is the situation itself. What is particular on machine I experienced the situation is that at machine starup, a service start and took most of machine resources for a while. In this time, I was able to log on (a Windows 2000 machine), and my application started immediately, with the error.
Did anybody hear somethiing like that?? For me, it sounds like Windows OS is not able to fully load its UI libraries, before application start... and this is weird, could be such a flaw? This lead a door to serious problems in how UI is designed... I will search myself further, but I also want your feedback, if such situation was encountered by someone.
I mention of course that, if the apllication is started late enough, it work normally on that machine. So, I'm not intrested in advices, but just in situation I mentioned: is possible that UI resources, needed by a desktop application, don't be available, at a certain moment?? - is a windows system!!!!!!
Any information with such a issue is greatly apreciated.
I can reformulate the problem, to avoid false hints: when is user32.dll loaded by OS, during the boot process??
Regards.
|
|
|
|
|
Did you link MFC statically or dynamically? It looks like it could not find the MFC DLLs, but it's just a guess. Try the Dependency Walker tool to check your executable for runtime dependencies, and verify if the machine has all the appropriates DLLs, or link everything statically.
I see dead pixels
Yes, even I am blogging now!
|
|
|
|
|
My application use MFC linked dinamically.
Dependency walker did not report problems, and as I said, the application run normally, if I move it from startup programs. The problem, as you point, could be that MFC is not available (loaded) at the particular time when application start. But for me this is really weird.
Thanks.
|
|
|
|
|
Hi there!
I want to change the name of a button name seen by the user at run time. Depending on how the user is using my program the name will change. I can use the code below to point to the button object, but I cannot figure out how to change the name of the item.
CButton* p = (CButton*)pVOS->dlg.GetDlgItem(IDC_BUTTON3);
The button name is initially set up in the resource editor.
Thanks,
Jerry
|
|
|
|
|
Use that instead:
pVOS->dlg.GetDlgItem(IDC_BUTTON3)->SetWindowText("Blah");
Hope this helps
|
|
|
|
|
Thanks for the info, have a good day.
Jerry
|
|
|
|
|
Is its possible to check if a new media is being inserted?
like a usb memory and so on. And if yes how?
|
|
|
|
|
WM_DEVICECHANGE
The WM_DEVICECHANGE device message notifies an application of a change to the hardware configuration of a device or the computer.
A window receives this message through its WindowProc function.
<br />
LRESULT CALLBACK WindowProc(<br />
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
|
|
|
|