|
You can get a handle to the screen like this:
CDC dc ;
dc.Attach(::GetDC(NULL)) ;
... drawing code
dc.ReleaseDC() ;
Roger Allen
Sonork 100.10016
|
|
|
|
|
Hi
I have a MFC based Modeless dialog application [A], developed in VC++ 6.0.
I have also a MFC regular dll [B], in which I have one modeless dialog as a resource.
I am loading this MFC regular dll [B] from my application [A],{ Using LoadLibrary() } and displaying its modeless dialog resource. This call to dll is made on some button click of my application [A].
Also, I have overridden CWinApp::OnIdle in my MFC regular dll [B].
But the problem is Dll's OnIdle is NOT called.
What could be the problem ????
One thing I have noted is when I override CWinApp::OnIdle
in my MFC dialog application [A], then this function is called. So, why NOT the Dll's OnIdle function called ?
Can anyone there help me get rid of this problem ?
Regards,
Prasad G.
|
|
|
|
|
Probably because OnIdle() is called when no messages are waiting in the app's message queue. Since it's the EXE that has the queue, the EXE's OnIdle() is called.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork ID - 100.10414 AcidHelm
|
|
|
|
|
I'm new to Visual C++ and MFC. I have just converted a DOS-based C program to MFC using MDI interface. I hope someone can help explain these 3 problems I can't seem to fix so far:
1. How do I create a maximised child window? I have tried WS_MAXIMISE in CChildFrame::PreCreateWindow but it doesn't work.
2. In one Dialog, my program can spend up to 5 minutes doing some data conversion and writing to disk. During this time, all buttons except Cancel are disabled. But the Cancel button refuse to appear as the default although I've set
m_cancel.SetButtonStyle(BS_DEFPUSHBUTTON);
m_cancel.SetFocus();
3. During this 5 minutes, the Cancel remain unclickable.
By the way, is it easier to program with Borland C++ Builder?
|
|
|
|
|
1/ Override OnInitialUpdate in the view and add this line:
GetParemtFrame()->ShowWindow(SW_SHOWMAXIMISED);
2/ Why don't you make cancel the default button in the resource editor instead ?
3/ That's because your task is taking up all of the time slice. You need to do the writing in a worker thread and then your main (UI) thread will become responsive.
I doubt it, if that were the case, why does no-one use it ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Hello all,
I was wondering about the scope of try...catch constructions over threads.
An example (very simplified example of existing code, where the Main_thread acts like a scheduler and the Worker_Threads are the 'processes'):
Main_thread
{
try {
}
catch( ... ) {
}
}
Worker_thread
{
try {
}
catch( condition ) {
}
catch( ... ) {
throw( something );
}
}
Is it possible to (or 'how to') catch the last throw from the Worker_thread into the Main_thread?
What is the nice way to do this?
Thanks in advance,
EiSl
|
|
|
|
|
Is it possible to (or 'how to') catch the last throw from the Worker_thread into the Main_thread?
The short answer is no you can't. Exceptions are intrinsically attached to the thread where they're produced, as are the mechanisms of stack unwinding involved.
An uncaught exception is simply swallowed by the system (though it is no good practice to let this happen).
An approach to having uncaught exceptions somewhat notified to the main thread is having a grand wrap-all try-catch in the worker thread that intercepts otherwise uncaught exceptions, translates this to a DWORD and return that result code, which the main thread can access with GetExitCodeThread() .
How do you translate exceptions to DWORD s? Depends on what kind of exceptions you're dealing with:
- If you don't have any a priori idea about the exceptions the worker thread can throw, then there's little you can do except perhaps returning 0 as "everything OK" and some other code for "some exception thrown".
- If the exceptions are derived from C++
std::exception , which provide a description with method what() , you can store this message in some global table and return a pointer to it.
- If the exceptions are copyable, you can store the exception objet itself in a table an return a pointer to it. Please note that this requires that the exceptions be of an exact known type, as derived types objects are not handled correctly (they're sliced).
- Some other ad hoc mechanism. You name it.
Hope this helped.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
IMHO it's not possible.
You have to do some thread syncronization between the Main_thread and Worker_thread.
----
Rui Lopes
|
|
|
|
|
Can I use CFileFind to search for a specific file on my computer?
I've seen that the class has to do with the CGopherFileFind and CFtpFileFind. So I guess it's perhaps impossible?
I've tried this but nothing appears:
void CFopiacjeDlg::OnButton1()
{
CFileFind finder;
BOOL bWorking = finder.FindFile("Fcc32.exe");
while (bWorking)
{
bWorking = finder.FindNextFile();
AfxMessageBox(finder.GetFilePath());
}
}
|
|
|
|
|
Findfile like that is only searching your current directory. (doth it search the PATH too? I can't remember.). But it isn't going to search your entire drive as you would want it to.
I use findfile in a self recursive function (it calls itself). Like this,
If you don't want the tree just chop those bits out.
This is a version that fills a tree with directories.
void CExIncView::FillDirTree()
{
char DRIVES[33];
DWORD DriveNumbers;
DWORD j;
int k,Image,ImageSelected;
CString lString;
HTREEITEM ParentList[33];
unsigned lDriveType;
m_Messages = " ";
UpdateData(FALSE);
//For each drive collect all directories
DriveNumbers = GetLogicalDrives();
j=1;
for(j=1,k=0;k<32;k++,j*=2)
{
if( DriveNumbers & j )
{
DRIVES[k] = 'A' + k;
}
else
{
DRIVES[k] = ' ';
}
}
//TEMP Put drives into tree
for(k=0;k<32;k++)
{
if( DRIVES[k] != ' ')
{
lString.Format("%c:",DRIVES[k]);
lDriveType = GetDriveType(lString);
switch(lDriveType)
{
case DRIVE_UNKNOWN ://The drive type cannot be determined.
Image = 2;
ImageSelected = 3;
break;
case DRIVE_NO_ROOT_DIR ://The root directory does not exist.
Image = 2;
ImageSelected = 3;
break;
case DRIVE_REMOVABLE ://The disk can be removed from the drive.
Image = 0;
ImageSelected = 1;
break;
case DRIVE_FIXED ://The disk cannot be removed from the drive.
Image = 2;
ImageSelected = 3;
break;
case DRIVE_REMOTE ://The drive is a remote (network) drive.
Image = 2;
ImageSelected = 3;
break;
case DRIVE_CDROM ://The drive is a CD-ROM drive.
Image = 4;
ImageSelected = 5;
break;
case DRIVE_RAMDISK ://The drive is a RAM disk.
Image = 2;
ImageSelected = 3;
break;
default:
Image = 2;
ImageSelected = 3;
break;
}
//ParentList[k] = m_pDirTree.InsertItem(lString,TVI_ROOT,TVI_SORT);
ParentList[k] = m_pDirTree.InsertItem(lString,Image,ImageSelected,TVI_ROOT,TVI_LAST);
m_pDirTree.SetItemData( ParentList[k], (DWORD) 50 );
}
else
{
ParentList[k] = NULL;
}
}
//For each parent traverse directory tree
for(k=0;k<32;k++)
{
if(ParentList[k] != NULL)
{
lString.Format("%c:",DRIVES[k]);
SearchDir(lString,ParentList[k]);
}
}
}
SearchDir is the self recursive function.
void CExIncView::SearchDir(CString sPath)
{
CString sFind,sTemp;
CString sBase,sBase2;
int Done;
WIN32_FIND_DATA lpFindFileData;
HANDLE SearchHandle;
sBase = sPath;
sFind.Format("%s\\*.*",sBase);
SearchHandle = FindFirstFile(sFind,&lpFindFileData);
if( SearchHandle != INVALID_HANDLE_VALUE)
Done = 0;
else
Done = 1;
while( !Done )
{
do
{
if( lpFindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY )
{
sTemp = lpFindFileData.cFileName;
if( (sTemp.Find("..") != -1) || (sTemp.GetLength()==1) )
;
else
{
sBase2.Format("%s\\%s",sBase,lpFindFileData.cFileName);
SearchDir(sBase2);
}
}
else
{
sTemp = lpFindFileData.cFileName;
if( sTemp.Find(m_FindThis ) != -1 )
{
if( m_iFind == 0 )
m_DatabaseLocation = sBase;
else
m_SourceFileDir = sBase;
}
}
}
while(FindNextFile(SearchHandle,&lpFindFileData));
Done = 1;
}
}
This FindFile can now be used to search for particular files (in this case on C
bool CExIncView::FindFile(CString &FName)
{
CString lString;
m_FindThis = FName;
lString.Format("C:");
SearchDir(lString);
return TRUE;
}
We do it for the joy of seeing the users struggle.
|
|
|
|
|
Hello All!
I have a custom draw list control, but it scroll bars has a standart look. Does anybody know how can I draw this scroll bars (I think it windows
style scroll bars, not controls) by my own? Or how can I replace this scroll bars by my custom draw controls without writing my own scrolling code?
|
|
|
|
|
I havn't done this myself, but I guess you can change color by overriding OnCtlColor. Check for CTLCOLOR_SCROLLBAR in msdn.
If you would like a more custom draw get the scrollbars from the window using GetScrollBarCtrl and subclass them to your own derivation of CScrollBar.
/moliate
|
|
|
|
|
Yes, I`m want a more custom draw, but GetScrollBarCtrl returns NULL for windows style scrollbars
I would like to know, how can I subclass this scrollbars?
|
|
|
|
|
Hello, I want to display a clock on a dialog box. I want to do both an "analog clock" as well as a "digital clock". If you can help me as to resources to help me do this I would appreciate it.
Thanks.
|
|
|
|
|
You'll probably have to code an analog clock yourself, but how you would go about doing this would be to create a TIMERPROC, using SetTimer, that is updated every 1000 milliseconds or 1 second, then you would draw the analog clock every time the timer is executed according to the time provided by GetSystemTime. If you wanted the digital equivlant you would of course, just use GetTimeFormat, and print it out to the screen.
For a digital type look try :
http://www.codeproject.com/staticctrl/cstatictime.asp
Try MSDN for information on the stuff listed above.
Nathan
modified on Sunday, April 19, 2009 12:26 AM
|
|
|
|
|
Thanks, that is what I figured I would have to do. Thanks for your input.
|
|
|
|
|
To draw the clock face you'll probably have to resort to trigonomentry. You might be able to precalculate some values, though I doubt it.
If you want something more complicated than simple lines you have to create a vector image then rotate the points. I think Joseph M Newcomer has written an article on this.. but it's late so I'll leave you to find it .
Remember -
sin x = OPP/HYP
cos x = ADJ/HYP
tan x = OPP/ADJ. You can use the radius of your clock minus some value (to get the correct size so you don't draw over the numbers of the clockface) for the length of the hypotenuse (sic?).
--
Andrew.
|
|
|
|
|
|
Migrating from VB, I could not find an easy way to trap a return keystroke and then act apon it on a CEDit control. Update and Change don't pass a parameter telling you which key has been pressed. Have I missed something?
- X
|
|
|
|
|
You will have to subclass the control to be able to catch keystrokes.
See SubclassDlgItemin MSDN. Then add a handler for the WM_CHAR message.
Cheers,
/Fredrik
|
|
|
|
|
hi all,
are there any ppls meet this situation? the same program but the outlook is different in 2 pcs. actually, the 2 pcs i used have identical configuration. the OS is newly installed.
would anyone give me any idea?
here is the link of 2 outlook.
http://mail.hkibrc.org/~chaze/question/question.html
regards,
jim
|
|
|
|
|
Well, the obvious difference is in the font. The 2 PCs must not be identical if the same dialog box has a different font on each one. It looks like one is using Large Fonts, which you can turn off in the Display Settings.
Regards,
Alvaro
|
|
|
|
|
I just added a function to a foo.cpp module which makes use of std::ifstream. This function was required for Project A. When I went back to compile another Project B, which also uses foo.cpp but not the new function, it grew in size by 80k.
I assume there are some extra libraries that are getting linked in. Is there anyway to prevent this from happening? How do I know which libraries are getting linked in?
Todd Smith
|
|
|
|
|
Hello,
Christian was so much help last time, I hope he is around for this post.
I got the open a new doc/.view working (thank you )
But now I need to create just a new doc. Can't just call it but its constructor (that'd be too easy).
The earlier example created a CDocument that was cast into my Doc type, but now since I am just pressing the File > New button, there is no file to load, etc...
A tad lost
Rob
|
|
|
|
|
Where you passed in a poiner to a path to the document to load, pass in NULL to create a new one.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|