|
Hi,
How can I seek in a CMemFile?
It looks like the CMemFile::Seek function hangs my program...
Thanks in advance,
Erik Hammar
|
|
|
|
|
Alright All, I have a small brain teaser to do with Toolbars. I have managed to setup a toolbar successfully in the CMainFrame section of MDI App. Every time I open a file / create a new file it adds the relevant information to the combo box (i.e. the name of the file). Its then possible that I do some operations on these files, the names of these operations are then also recorded IN ORDER in the combo box. However, since I have an MDI app, and I`ve used the CMainFrame section to house the combo box, it is possible that the user mixes up the entries in the combo box that are associated with the different windows. I would like to be able to keep them separate, so that when the user clicks on a particular window, the combo box reflects the changes I`ve made to that one and that one only (and if I re-activated the other window it would re-display all the changes to that one etc.). I would appreciate any advice on this, even if it was to just tell me where to store the combo box control or how to switch back and forth different combo boxes as the different windows are activated.
Cheers again guys,
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
I would recommend keeping the list of changes you have made in the document object. Then wehn tyhe user switches document, (or toa different view), you can handle the OnSetActive of that view and populate the combo box in the toolbar. Something like:
void CMyView::OnSetActive(bool m_bActivate)
{
if (m_bActivate)
{
CComboBox* pCombo = &((CMainFrame*)(AfxGetApp()->m_pMainWnd))->m_ComboBox ;
pCombo->ResetContent() ;
}
}
Its a bit rough and done from memory so it may be a little bit buggy
Roger Allen
Sonork 100.10016
|
|
|
|
|
After I had written the question, for some unknown reason (I`ll call it fate), this exact same solution came into my head. I was, in fact just about to delete this thread thinking that no-one would respond so quickly, amazing. I would, however, like to thank you for responding and re-affirming this solution, because it came from nowhere in my head, and I always tend to think "is this the best solution - mmmm I dunno", but since your response I have no fear.
Thanks Roger, very much appreciated,
Alan.
P.S. your solution seems pretty damn good, if thats "a bit rough" I feel quite inadequate .
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
I make a MFC App (Visual C++ Project) using a CHtmlView. I run this MFC App and I open a "Word Document" on CHtmlView through Navigate2("WordDoc.doc",0,NULL) and I can updated it, it's fun. But if I run Microsoft Word (in the same time that MFC App) to work on another Word Document and atfer a close Microsoft Word, when I come back on my MFC App, I can't access on my "Word Document" (no cursors). To check this problem, you can tried to use MFCIE sample on Msdn to open a "Word Document", it's the same result ...
Thanks....
|
|
|
|
|
I have a dialog based app, no doc/view, in which I have a listview control, and I want to add a context menu, so that when the user right clicks in the list view, a context menu pops up, and the user can choose to add, delete, etc. an entry. Do you have to have doc/view in order to have a context menu? If so, is there a way around this?
|
|
|
|
|
You can do this quite easily. First Create a menu resource
MyPopup->Item 1
Item 2
...
Then handle the NM_RCLICK message for the list control and add code such as this
CMenu menu ;
CMenu *pPopup ;
CPoint point ;
int item_selected ;
GetCursorPos(&point) ;
menu.LoadMenu(IDR_MENU_RESOURCE_ID) ;
pPopup = menu.GetSubMenu(0) ;
item_selected = ::TrackPopupMenuEx(pPopup->m_hMenu, TPM_RETURNCMD | TPM_NONOTIFY, point.x, point.y, m_hWnd, NULL) ;
switch (item_Selected)
{
case ID_MENU_ITEM1 :
...
break ;
}
You use the TPOM_RETURNCMD flag so that you don;t have to handle the command as WM_COMMAND message. This allows you to keep all the code together for the different menu options in one place. You also don;t have to write all the ON_COMMAND macros and function prototypes
Enjoy
Roger Allen
Sonork 100.10016
|
|
|
|
|
Hi everyone,
I've posted a thread regarding the retrieval of sound and graphics card info such as driver name, manufacturer and version.
Many of the answers I have received all boils down to using WMI (Windows Management Instrumentation) but after using it I realize it's an enormous overkill for my simple needs and that it is not supported for win 95/98 unless you install it yourself.
There must be another, more standard way to get the display and sound info, right...?
If you know how or can point me in the right direction, I'd be VERY grateful!
/Tommy
|
|
|
|
|
I built an application using Micro. visual c++. When in debug run it turns nothing...but when I compile/build in Win32 Release n try to execute this error occur in the message box in windows 2000
"The instruction at "0x00430432" reference memory at "0x0000000c". The memory could not be "read" ".
n I click ok
again it emerge with different error message box,
"The instruction at "0x0042377c" reference memory at "0x00000004". The memory could not be "read" ".
any idea what is this error
|
|
|
|
|
i can't really help you... but this article may help...
http://www.codeproject.com/debug/survivereleasever.asp
hope this helps
bernhard
"There are three roads to ruin: women, gambling and technicians. The most pleasant is with women, the quickest is with gambling, but the surest is with technicians." Georges Pompidou
|
|
|
|
|
Hi Guys,
Did it ever happened to you that you wanted to send some big files to a friend in small pieces by mail and you needed to do all the hard work of using one application to split it and then attach the pieces your self...
I had this problem and I found an application that does this for you and more and I want to recommend it.
It is called "Moving" application and it can be downloaded from the site:
http://www.domoving.com
It does the above in a very easy way and you can also ask for confirmation that the reciever who got your pieces succeeded in opening them.
It also bypass firewalls so I can send exe,mp3,etc. files to friends that are "blocked" and can get this kind of mail.
Eran
|
|
|
|
|
10x for your recommendation,
this a really cool tool, one of the best I bump into lately.
|
|
|
|
|
I need to draw an image onto a part of the Desktop!If anybody knows how to do it please help me with a a sample!
Thanks in advance!!
|
|
|
|
|
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
|
|
|
|
|