|
The problem lies in the class in which you're trying to put a handler for it.
In an MDI application it is the View class that gets the first chance to handle the message.
If there is no handler, the control goes to the document class.
Only then does the child frame get a chance to handle the message.
What you're seeing is the default implementation of the document class.
You can catch the message by adding the handler in the view class or the document class.
|
|
|
|
|
Hi friends
How to compact a database using CDatabase class or any other method in Visual C++
thanks in advance-kk.tvm-
|
|
|
|
|
See, for instance, from the competitors : "Compact an Access Database Programmatically".
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi, The OutlookDemo Sample of MFC new Feature pack implements a very good style of CMFCOutlookBarTabCtrl class that when you configure the gui to look in office 2003 and office XP modes the tabs of the CMFCOutlookbar Open and go upward by clicking on them but I couldn't found what to do reach this style of tabs through the sample source code. if any one knows the answer I will be thankful if he could modify my below code so i could reach that style.
m_wndOutlookBar.SetMode2003(true);
m_wndOutlookBar.Create(_T("test"), this, CRect (50, 50, 500, 500), ID_VIEW_OUTLOOKBAR, WS_CHILD | WS_VISIBLE | CBRS_LEFT);
m_wndOutlookPane1.Create (&m_wndOutlookBar,
AFX_DEFAULT_TOOLBAR_STYLE, ID_OUTLOOK_PANE_GENERAL, AFX_CBRS_FLOAT | AFX_CBRS_RESIZE);
m_wndOutlookPane1.EnableDocking (CBRS_ALIGN_ANY);
m_wndOutlookPane1.AddButton (theApp.LoadIcon (IDR_MAINFRAME), L"Open", ID_APP_ABOUT);
m_wndOutlookPane2.Create (&m_wndOutlookBar,
AFX_DEFAULT_TOOLBAR_STYLE, ID_OUTLOOK_PANE_SPECIAL, AFX_CBRS_FLOAT | AFX_CBRS_RESIZE);
m_wndOutlookPane2.EnableDocking (CBRS_ALIGN_ANY);
CMFCOutlookBarTabCtrl::EnableAnimation(TRUE);
CMFCOutlookBarTabCtrl* pOutlookBar =
(CMFCOutlookBarTabCtrl*) m_wndOutlookBar.GetUnderlyingWindow ();
pOutlookBar->EnableInPlaceEdit(TRUE);
pOutlookBar->EnableAnimation(true);
pOutlookBar->EnableScrollButtons();
pOutlookBar->EnableTabSwap(true);
(CMFCBaseTabCtrl*)pOutlookBar->EnableTabDetach(0,true);
pOutlookBar->AddTab (&m_wndOutlookPane1, L"General", (UINT) -1, TRUE);
pOutlookBar->AddTab (&m_wndOutlookPane2, L"Special", (UINT) -1, TRUE);
|
|
|
|
|
I Found Answer By my self ,And It was about the method
m_wndBarOutlook.SetMode2003(TRUE);
Because in the sample program of MSDN in the 2003 style and XP Mode it changes the way I like I never think of that to have this style
I should use it the following way
m_wndBarOutlook.SetMode2003(FALSE);
|
|
|
|
|
I run a worker thread like this:
m_first = AfxBeginThread(MyThreadProcTT1, segmentation,THREAD_PRIORITY_ABOVE_NORMAL);
in the MyThreadProcTT1, i run four worker threads like this:
CWinThread* first=NULL;
first = AfxBeginThread(MyThreadProc, pNewObject,THREAD_PRIORITY_ABOVE_NORMAL);
second = AfxBeginThread(MyThreadProc1, pNewObject1,THREAD_PRIORITY_ABOVE_NORMAL);
third = AfxBeginThread(MyThreadProc2, pNewObject2,THREAD_PRIORITY_ABOVE_NORMAL);
forth = AfxBeginThread(MyThreadProc3, pNewObject3,THREAD_PRIORITY_ABOVE_NORMAL);
WaitForSingleObject(first->m_hThread, INFINITE);
WaitForSingleObject(second->m_hThread, INFINITE);
WaitForSingleObject(third->m_hThread, INFINITE);
WaitForSingleObject(forth->m_hThread, INFINITE);
in most of the time, the program work fine. But in some situations, the program halts and do not anything!
Is there anyone can help me!
Best,
MJM
|
|
|
|
|
I spot an issue in your code: All threads have their priorities set to THREAD_PRIORITY_ABOVE_NORMAL , which I think could be avoided. What is your justification for doing this?
mostafa_pasha wrote: But in some situations, the program halts and do not anything!
And what does that mean? Have you used the debugger to step into the code? Have you verified all the WaitForSingleObject calls have returned (as you're asking the program to wait for an INFINITE amount of time)?!
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
I taught coping the software is for thread priority.So i tried to change the priority to ABOVE_NORMAL.
About debugging,
i changed the code:
WinThread* first=NULL;
first = AfxBeginThread(MyThreadProcT, &pmom1,THREAD_PRIORITY_ABOVE_NORMAL);
if(first == NULL)
{
AfxMessageBox(_T("Can not run a thread!!!"));
return;
}
CWinThread* second=NULL;
second = AfxBeginThread(MyThreadProcT1, &pmom2,THREAD_PRIORITY_ABOVE_NORMAL);
if(second == NULL)
{
AfxMessageBox(_T("Can not run a thread!!!"));
return;
}
if (WaitForSingleObject(first->m_hThread, INFINITE) == WAIT_FAILED)
{
ErrorExit(TEXT("Thread_First")); // show the GetLastError
}
if (WaitForSingleObject(second->m_hThread, INFINITE))
{
ErrorExit(TEXT("Thread_Second")); // show the GetLastError
}
I caught this message box:
Thread_Second failed with error 6: The Handle is invalid!!!
Does it mean second thread finish before the the first thread?
Best
MJM
|
|
|
|
|
mostafa_pasha wrote: Thread_Second failed with error 6: The Handle is invalid!!!
It could mean that the thread was not even started. Remember that these operations are completely asynchronous. The code has reached the WFSO call does not mean the thread creation function called above that has successfully spawned the thread by then.
I'd strongly recommend that you get your basics right. Read this essay by Dr. Joseph Newcomer, which covers many aspects: Worker Threads[^]
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Unfortunately, I used SetEvent , .... in the debug mode, everything is OK.
in the release mode, it seems that the threads can not start!!!
Best,
MJM
|
|
|
|
|
mostafa_pasha wrote: Unfortunately, I used SetEvent , .... in the debug mode, everything is OK.
in the release mode, it seems that the threads can not start!!!
Please read this: Debug vs Release[^]
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Language: Visual C++ 6.0; MFC app with CWinApp-based class
OS: WinXP
I use a COM component (http://www.emailarchitect.net/webapp/popcom/) in MFC app. I release it BEFORE call of ExitInstance; in ExitInstance I call CoUninitialize. This CoUninitialize hangs. If I call CoUninitialize not from ExitInstance but right after the COM object is released - no hangs.
All I know about this COM component is it uses asyncronous mode amd uses sink interfaces for client notification. Partially it uses ATL's method DispEventAdvise. My application has not its own cycles of message processing - only standard MFC cycle in CWinApp.
The hang does not depend on what was used to initialize COM: CoInitialize( NULL ) or CoInitializeEx(NULL, COINIT_APARTMENTTHREADED).
|
|
|
|
|
Please check the return value of your CoInitialize call, I suspect you hit this [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I did it; it returns S_OK. Ni more calls of CoInitialize* in teh program
|
|
|
|
|
I need to display a huge size file(1GB) content in a dialog, when it is popup to the user. I tried to read the file content in oninitdialog(), but since huge size, dialog takes some more time to display. Is there any other way to read and display the file content with minimum time?
Kindly help me asap!
|
|
|
|
|
You can use overlapped or asynchronous read operations on the file.
This way you can initiate the read from OnInitDialog where the read function will immediately return and complete later.
Read about it here - Synchronous and Asynchronous I/O[^]
|
|
|
|
|
Thanks a lot Superman. But Is it possible to do it in any other function excluding oninitdialog()? This is just my doubt.
|
|
|
|
|
If you're using overlapped/asynchronous file read, you could initiate it in the constructor of your dialog class or globally when the program is started.
You can also create a new thread in which the file read can be done.
In this case you will have to device a communication mechanism using messages so that the thread can notify the main UI thread of the completion of the read and pass the buffer containing the contents of the file.
|
|
|
|
|
Thanks for your inputs! But my requirement is to display whole file content. Anyway superman idea is apt for my query.
|
|
|
|
|
Prabhu092009 wrote: But my requirement is to display whole file content
Wow, your users really want to look at over 1 gig of data ?
Anyway, whatever the method you use, reading 1gig+ from the disk is going to take some time anyway, not only reading the file, but allocating the memory to hold that data; and probably will crash the application because the control you will use to display the data will not work with that amount of data.
Maybe have look at memory mapped files ?Watched code never compiles.
|
|
|
|
|
Why possibly would you display the whole file content?
Just use paging as suggested and display only what's actually visible. Why don't you understand it?!
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Since you cannot display the whole file content (I suppose), why don't you load just the needed part?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
DeviceIoControl with IOCTL_DISK_GET_DRIVE_LAYOUT parameter does not returns correct values for drives in dynamic disk. For basic disk all values are correct.
DWORD i;
HANDLE handle = CreateFile("\\.\PhysicalDrive0", ,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0);
DRIVE_LAYOUT_INFORMATION *drive_layout;
int buf_size = sizeof(DRIVE_LAYOUT_INFORMATION) + 8* sizeof(PARTITION_INFORMATION);
DeviceIoControl(handle,IOCTL_DISK_GET_DRIVE_LAYOUT,NULL,0,(BYTE*)drive_layout,buf_size,&i,NULL);
for (i = 0; i < drive_layout->PartitionCount; i++)
{
PARTITION_INFORMATION * partinfo = &drive_layout->PartitionEntry[i];
// PARTITION_INFORMATION keeps starting offset, drive size and hidden sectors for any drive. and i can get all using partinfo pointer.
}
If i have a disk of 80 gb size. Suppose First drive (C:/) start at sector 63 and size is 20 gb, then second drive (d:/) start at offset 40 gb and size is 20 gb then above function returns 20 gb as start offset for second drive. While the correct value is 40 gb. (In this disk offset from 20 gb to 40 gb is free and it has no partition).
I also tried to open second drive (CreateFile("\\.\d:",..) and call DeviceIoControl with IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS parameter but it does not returns correct value for starting offset and drive size.
Please suggest.
|
|
|
|
|
Hi all,
I want to read the datas in a CSV file line by line.How can i do this? Can anyone please help me?
Thanks,
|
|
|
|
|
CSV is a text file.
If you're using MFC, use the CStdioFile class and its ReadString method to read it line by line.
Or you can use std::ifstream to open the file for reading and then use the getline function to read line by line.
|
|
|
|