|
Hello Judy, yes, thank you for the suggestion. I actually did go that route using the DocTemplate to find all the views that I needed to check before closing. I chose this method because I also have multiple types of documents in the app - here is the code: forgive the mess, I'm self-taught
void CMainFrame::OnClose()
{
#ifdef _USE_CMC6INVOICE_THREAD_
POSITION pos, posView;
pos = theApp.m_pCmc6InvoiceDocTemplate->GetFirstDocPosition();
while(pos != NULL)
{
CDocument *pDoc = theApp.m_pCmc6InvoiceDocTemplate->GetNextDoc(pos);
if(pDoc!= NULL)
{
posView = pDoc->GetFirstViewPosition();
while(posView != NULL)
{
CView * pView = pDoc->GetNextView(posView);
if(pView->IsKindOf(RUNTIME_CLASS(CCMC6InvoiceView)))
{
CCMC6InvoiceView * pInv = (CCMC6InvoiceView *) pView;
if(pInv->m_clsInvoice->m_pThread != NULL)
{
if(pInv->m_clsInvoice->m_pThread->GetActivityStatus() == THREAD_NOTPREPARED_TO_TERMINATE)
{
TRACE("Mainframe: OnClose() ->CMC6InvoiceView Thread Busy, Can't close yet...\n");
Sleep(200);
PostMessage(WM_CLOSE);
return;
}
}
}
}
}
}
#endif
#ifdef _USE_BACKGROUND_THREAD_
DWORD dwExitCode;
m_pBackThread->Stop(dwExitCode, 0);
if(m_pBackThread->GetActivityStatus() == THREAD_NOTPREPARED_TO_TERMINATE)
{
TRACE("Mainframe: OnClose() ->BackProcess Thread Busy, Can't close yet...\n");
Sleep(200);
PostMessage(WM_CLOSE);
}
else
{
TRACE("Mainframe: OnClose() ->Can close now\n");
m_pBackThread->Stop(dwExitCode);
SaveCommandBars(_T("CommandBars"));
CXTPDockingPaneLayout layoutNormal(&m_paneManager);
m_paneManager.GetLayout(&layoutNormal);
layoutNormal.Save(_T("NormalLayout"));
CMDIFrameWnd::OnClose();
}
#else
SaveCommandBars(_T("CommandBars"));
CXTPDockingPaneLayout layoutNormal(&m_paneManager);
m_paneManager.GetLayout(&layoutNormal);
layoutNormal.Save(_T("NormalLayout"));
CMDIFrameWnd::OnClose();
#endif
}
|
|
|
|
|
I want to create a console like dialog, I was thinking like in a multi-line edit boxt, but I don't know how so I need some ideas to start with.
It should work like a "real" console, where you only can write at the prompt, only delete what you just have written, but not yet executed and so on.
Many games have a console like this, to send messages etc, maybe there's some code to start with?
What the result should be is an interactive console for Python, but intergrated in my application as a modeless window or a dialog. Python is easy to embed with, for example PyRun_InteractiveLoop, reading and writing to stdin/out.
Any ideas how this can be archived?
Thanks!
|
|
|
|
|
Well you can paint it back bg with CTL_COLORSTATIC notification message, you can use keyboard handler to do pretty cool stuff or you can simply trace for keywrds like record for keyboard msgs in wnd proc, and use gettickcount know make if a word is typed.then you can simply use GetDlgItemText to get text then append, i recommend use sstream.h for string formatting. then simply set the text to edit box with setdlgitemtext
|
|
|
|
|
Hi,
Is there any way to execute XQuery through MFC Code, I know How to use MSXML.DLL to load xml documents and navigate the XML document But I am looking for a method like ExecuteSQL("") to execute my XQuery statements?
|
|
|
|
|
When my article will be publish?How many days in general?Who have the right to publish the article?
|
|
|
|
|
The Lounge [^] is possibly more appropriate.
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,
In my application I need to create a employee.dbf file and reading that employee information into employee structure and filling that information into emplyee dialog box.
kir_MFC
|
|
|
|
|
What is a dbf file? Is it a database file?
|
|
|
|
|
|
Are you talking about the ancient dBase database file?
--
Si dos montan un caballo, uno debe ir detrás.
|
|
|
|
|
There are information on dbf file structures available on the web. I suggest you do a search to find the info.
|
|
|
|
|
ODBC would probably be the easiest. If you are using MFC, check out the CRecordset and CDatabase classes.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Did you see Database[^]?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hi,
As i want to display two dialogs and im hiding mainframe.Just i will do all this operations through the buttons in these two dialogs.
So i did in App class as follow
pMainFrame->ShowWindow(SW_HIDE);
pMainFrame->UpdateWindow();
pMainFrame->AlarmBanner();
pMainFrame->ToolTab();
In Mainframe.cpp
void CMainFrame::AlarmBanner()
{
CAlarmBanner *oAbanner;
oAbanner = new CAlarmBanner;
oAbanner->Create(IDD_ALARMBANNER,this);
oAbanner->ShowWindow(SW_SHOW);
}
void CMainFrame::ToolTab()
{
CToolTab *otoolbar;
otoolbar = new CToolTab;
otoolbar->Create(IDD_TOOLBAR_DIALOG,this);
otoolbar->ShowWindow(SW_SHOW);
}
My problem,when i started it is continously flickiering..even it does not open properly.
Wats the mistake..what can i do to avoid that?
By commenting any dialog calling code,the other one works perfectly.But i want to display this two dialogs as one in top of screen and other one in left side of screen.
Anu
|
|
|
|
|
I could not figure out why exactly it is flickering but it seems following points worth considering:
1) pMainFrame->UpdateWindow(); call looks unnecessary.
2) Heap allocations made by using new operator need to be deallocated by using delete operator otherwise results in memory leak.
3) The dialogs need to be explicitly destroyed by calling DestroyWindow() function.
|
|
|
|
|
Now its working .What i changed is.
I gave setwindowpos in OnWindowPosChanging(WINDOWPOS* lpwndpos) in each dialog.Now i replaced that in to OnInitDialog().
Anu
|
|
|
|
|
Flickering could be due to a endless try to refresh the dialogs.
In addition to the previous answer I would take a look on the OnPaint, UpdateWindow or similar messages, and on the interactions between one and the other dialog as well (if there are such interactions), the problem could be there.
I mean...
A updates and try to update B, then B updates and try to update A, so it starts another time and has no end.
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
hi every one
i need to implemtion of unistd.h in the windows
would you help me please?
Thanks a lot
|
|
|
|
|
Cygwin?
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Why do you need it?
Could you use Cygwin [^] environment?
[added]
Damned monkeys!!!
[/added]
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 didn't use cygwin alredy and I want to find a solution except this. if there isn't other way please tell me how can i use it?
thanks a lot.
|
|
|
|
|
How do I get the hToken needed for CreateProcessAsUser? I have a DLL that is loaded runs from the context of user1 and then from user2. From user2, I want to create a process as user1.
From MSDN:
BOOL WINAPI CreateProcessAsUser(
__in_opt HANDLE hToken,
__in_opt LPCTSTR lpApplicationName,
__inout_opt LPTSTR lpCommandLine,
__in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes,
__in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes,
__in BOOL bInheritHandles,
__in DWORD dwCreationFlags,
__in_opt LPVOID lpEnvironment,
__in_opt LPCTSTR lpCurrentDirectory,
__in LPSTARTUPINFO lpStartupInfo,
__out LPPROCESS_INFORMATION lpProcessInformation
);
What I want to do is something like this:
1. user1 process loads my DLL
2. my DLL gets the current process hToken (???this is the part i don't get???)
3. my DLL stores that in a txt file.
4. user1 process closes
5. user2 process starts and loads my DLL
6. my DLL reads all the needed data from txt file
7. my DLL starts a process as user1.
user2 process is always guaranteed to run only *after* user1 process. They don't run simultaneously.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
LogonUser() function can be used to get the token.
|
|
|
|
|
I don't have the password for the user, which LogonUser requires.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
In that case you can enumerate all processes to find out the PID for explorer.exe
Use OpenProcess() API to get process handle for explorer.
Use OpenProcessToken() API to get the token handle for explorer.exe.
Use the this token handle in the CreateProcessAsUser() API.
It would work because explorer.exe runs in the logged-in user's account.
|
|
|
|