|
|
Thanks. That's pretty much exactly what I was hoping to find.
|
|
|
|
|
This is my code:
-----------------------------------
void CMainDlg::OnButtonData()
{
CDemo dlg;
dlg.DoModal();
}
----------------------------------
and all is right.(not warnings or errors by compailer)
but when I press on cancle in run time in the Demo dialog I gets error message:
"illegal operation..." and all the program shut down .
This is the cod of OnCancle:
______________________________________
void CDemo::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
_______________________________________
Maybe it is because I need to give the constructor of Demo dlg the pointer to main CWnd ??? How do I this ???
|
|
|
|
|
You don't need to pass in the HWND, if NULL it just uses the desktop window.
Are there any controls on the demo dialog that may not be created or instantiated correctly?
|
|
|
|
|
This might not matter at all, but people generally call DoModal in an "if" statement, such as:
if (dlg.DoModal() == IDOK)
{
//do stuff
}
This way, when they hit cancel the program doesn't try to do anything you don't want. It seems like there might be some code that you only want executed when they click "OK", so you might try putting that inside the if block.
Jake
|
|
|
|
|
As I understand it the easiest way to get blinking static text, is to create a class who's base class is CStatic. I have overrridden the WM_TIMER message handler, and created a member function, StartBlink(). I have a boolean variable that determines whether the text is shown or not, and I try to simply use ShowWindow() to get a blinking affect. My code:
void CStaticBlink::OnTimer(UINT nIDEvent)
{
if(m_bVisible == TRUE)
ShowWindow(SW_HIDE);
else
ShowWindow(SW_SHOW);
m_bVisible = !m_bVisible;
CStatic::OnTimer(nIDEvent);
}
void CStaticBlink::StartBlink()
{
SetTimer(1, 500, NULL);
}
What am I missing, using the debugger, I never make it into OnTimer()
|
|
|
|
|
I dunno, because I did this:
void CBlinkStatic::OnTimer(UINT nIDEvent)
{
if (nIDEvent == 42)
{
ShowWindow(m_bBlink ? SW_SHOW : SW_HIDE);
m_bBlink = ! m_bBlink;
}
CStatic::OnTimer(nIDEvent);
}
void CBlinkStatic::StartBlink(int speed)
{
SetTimer(42,speed,NULL);
}
and it works a treat. Are you sure your start method is called ?
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
Yeah, I did that exactly, and made sure I called the start function, and made sure the control variable was of the correct class.
enum { IDD = IDD_PROGRESS_DLG };
CStaticBlink m_ctrlDownload;
void CStaticBlink::OnTimer(UINT nIDEvent)
{
if(nIDEvent == 42)
{
ShowWindow(m_bVisible ? SW_SHOW : SW_HIDE);
m_bVisible = ! m_bVisible;
}
CStatic::OnTimer(nIDEvent);
}
void CStaticBlink::StartBlink()
{
SetTimer(42, 500, NULL);
}
void CProgressDlg::LoadDialog()
{
m_ctrlErrorCheck.StartBlink();
}
|
|
|
|
|
And you traced to ensure that StartBlink is called ? If so, I am at a loss ? I created the code I posted and ran it and it worked a treat, like I said. There is no reason I can see for it not to.
BTW it can be any number, I only choose 42 because it's the answer to the ultimate question. Just so I've not muddied the waters needlessly
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
Ok its a different problem than we thought. The Timer and blinking code was fine. The situation is this. My program error checks a file (which takes 5 seconds or so) and three other comparable (length) operations, before it downloads this file to a device. So, I figured a progress bar would be overboard for the 5 second operations, but do have one for the download. I thought I would just blink text when the program is doing each operation. Well if I run the program all the way through, the text starts blinking AFTER all the operations and download is complete. So it seems as though my download isn't allowing other "things" to run in side my application while it is downloading, though all other windows apps are unaffected.
Do I need to send some sort of update message or something?
Thanks for all your help.
|
|
|
|
|
Its because my dialog is modaless...
|
|
|
|
|
Doesn't matter that the dialog is modal or modalless, the program can only execute the commands one at a time (one THREAD of execution). For situations where you need to keep the interface going while the background is doing some immense operations, you would most likely want to use another thread (see MSDN CWinThread) to perform the background operations. Then in your background thread, occastionally stop processing (Sleep() or MSDN WaitForSingleObject()) to allow the UI thread to process.....
|
|
|
|
|
Does that mean you've fixed it, or just found the problem ?
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
Is the ON_WM_TIMER() macro in the message map of your class?
|
|
|
|
|
I've made an application and I cannot change the icon created when the program saves a file. I have edited the icon (IDR_...TYPE) in the resources, change it and recompiled it, but the program always creates the default doc icon. What could be the problem?
|
|
|
|
|
I think you not only have to edit the resources, but also you need to define and initialize in the "OnDraw" function.
|
|
|
|
|
Do you mean the icon seen from Explorer, or when the DOC is open in the App?
1. From Explorer - You have to create an association between your App and the file type
2. In your App - Just create a new icon, and name it whatever the icon file is named in your App/Res directory. Overwrite that icon with the new one, and it will display properly.
|
|
|
|
|
OK,
I've got an SDI app. with some splitters in it, a treeview and a listview, I want to be able to drag and drop from one to another. What's the best way to go about this? I've never done any drag & drop before in any language, so all of this is new, any hints are welcome. I've had a look through some of the demo code available on this site, it all seems overly complex, I don't need to accept files from external apps, or send to them, all drag and dropping is limited to my split views.
Tips anyone?
TIA
Jon
|
|
|
|
|
Hi all,
I've succeeded in adding all sorts of sliders and edit controls into toolbars. Now I'm trying to add some CButtons and it isn't working - the toolbar still shows the separator and no CButton.
Do CToolBars not allow CButtons? Is there a way to find out which controls are allowed and which aren't?
thanks,
Jake
|
|
|
|
|
Alright, I got that working Sorry, and thanks anyway.
|
|
|
|
|
I have a list class list<cmyclass> from which I have declared a typedef for the iterator. list<cmyclass>::iterator myIterator;
problem is, i cannot seem to cast myIterator to anything, not even to a variable of type CMyclass*. I need to cast the iterator to a DWORD so that I can store it in an MFC LVITEM struct for later use. I have no problem whatsoever if I use a vector instead of a list! I can happily cast away my vector iterator to a DWORD or LPARAM or even a CMyclass*.
Whats the deal?
Thanks in advance, BTW i am using VC 6.0 sp 5 and I have applied the latest dinkumware patches to my STL.
|
|
|
|
|
I have used a STL list in the manner you discribe.
Perhaps a snippet of the code would allow us to see what you are doing and why it isn't working for you.
|
|
|
|
|
Vector iterators are often ordinary pointers, but you can't trust on that. There's absolutely no guarantee that an iterator will fit in a DWORD or a void*.
|
|
|
|
|
The *address* of the iterator should fit nicely into a DWORD, or for that matter a void*. Of course, you have to cast away the type.
|
|
|
|
|
you can follow this scheme:
* use vector instead of list
* store the index instead of an iterator (this will fit in a DWORD)
* add a constructor to myIterator taking as argument the index, like this
myIterator(DWORD index):
list::iterator(begin()+index)
{}
I hope you get the point, just fill in the details. Good luck
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|