|
Can you show code snippet?
|
|
|
|
|
You could manually send a WM_CLOSE message to your dialog handle.
For instance if the handle to your dialog is:
HWND MyDialog;
SendMessage(MyDialog, WM_CLOSE, 0, 0);
KR
|
|
|
|
|
I have a CDialog on which I have a extension CToolbar ctrl. I have extended the CTOolbar so that I can use OnKickIdle from my CDialog to get the ON_UPDATE_COMMAND_UI for my CToolbar buttons.
My question is this: How can I capture the tab key to also tab through the CToolbar buttons and also tab through the CDialog menu's?
|
|
|
|
|
What does your OnKickIdle() look like? I have used this kind of code:
LRESULT CMyDTestDlg::OnKickIdle(WPARAM wParam, LPARAM lParam)
{
UpdateDialogControls(this, FALSE);
AfxCallWndProc(this, m_hWnd, WM_IDLEUPDATECMDUI, TRUE, 0);
SendMessageToDescendants(WM_IDLEUPDATECMDUI, TRUE, 0, TRUE, TRUE);
return 0;
}
Best wishes,
Hans
|
|
|
|
|
My code looks like this:
LRESULT CCTSubmiterDlg::OnKickIdle( WPARAM wParam, LPARAM lParam )<br />
{<br />
SendMessageToDescendants( WM_IDLEUPDATECMDUI, wParam, lParam, TRUE, TRUE );<br />
<br />
CMenu* pMainMenu = GetMenu();<br />
CCmdUI cmdUI;<br />
<br />
for (UINT n = 0; n < pMainMenu->GetMenuItemCount(); ++n)<br />
{<br />
CMenu* pSubMenu = pMainMenu->GetSubMenu(n);<br />
cmdUI.m_nIndexMax = pSubMenu->GetMenuItemCount();<br />
<br />
for (UINT i = 0; i < cmdUI.m_nIndexMax;++i)<br />
{<br />
cmdUI.m_nIndex = i;<br />
cmdUI.m_nID = pSubMenu->GetMenuItemID(i);<br />
cmdUI.m_pMenu = pSubMenu;<br />
cmdUI.DoUpdate( this, FALSE );<br />
}<br />
}<br />
<br />
return 0;<br />
}
|
|
|
|
|
Andy H wrote: My question is this: How can I capture the tab key to also tab through the CToolbar buttons and also tab through the CDialog menu's?
AFAIK, there's no tab-through-buttons functionality in a toolbar (or am I wrong?).
Do you have a way to implement that functionality?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
You could just do it manually in whatever your message loop is (GetMessage, PeekMessage etc), by checking the MSG wParam to see if it's the tab key, then check to see if the message occurred in your Toolbar ctrl or your CDialog, and if so, tab to whatever you want.
KR
|
|
|
|
|
I have a MDI application which has a muliple dialog windows. One of these dialog windows needs to be update on regular basis. I am assume the best way to accomplish this is to add/create a OnTimer function and in it add code to refresh the window. What is the syntex for accomplish this.
<br />
void Lenze8200_Dlg::OnUpdate(CView* , LPARAM , CObject* )<br />
{<br />
Red_ON = AfxGetApp()->LoadIcon(IDI_RED_ON_LED); <br />
Red_OFF = AfxGetApp()->LoadIcon(IDI_RED_OFF_LED); <br />
Green_ON = AfxGetApp()->LoadIcon(IDI_GREEN_ON_LED); <br />
Green_OFF = AfxGetApp()->LoadIcon(IDI_GREEN_OFF_LED); <br />
Led_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); <br />
<br />
if( G2MainApp.pitch_is_connected() == false ) <br />
{<br />
m_iconPitchConnected.SetIcon( Red_ON );<br />
}else{<br />
m_iconPitchConnected.SetIcon( Green_ON );<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
void Lenze8200_Dlg::OnTimer(UINT nIDEvent)<br />
{<br />
<br />
CFormView::OnTimer(nIDEvent);<br />
}<br />
<br />
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
void Lenze8200_Dlg::OnTimer(UINT nIDEvent)
{
if (m_pDialog && ::IsWindow(m_pDialog->m_hWnd))
m_pDialog->RedrawWindow();
CFormView::OnTimer(nIDEvent);
}
|
|
|
|
|
Hans,
I get a compiler error when, i add this code. regarding &&. However, I might be because, i am not using the right object identify for m_pDialog. What should m_pDialog represent? How do find the name of the class i should use here
Where is it define in the project. MFC create the following classes for me.
MainFrm
ChildFrm
G2Motion
G2MotionDoc
G2MotionView
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
ScotDolan wrote: What should m_pDialog represent?
Sorry, I was not clear. m_pDialog = pointer to dialog that you created. Of course, the dialog may also be a class variable, so you could just say:
m_MyDialog.RedrawWindow();
Best wishes,
Hans
|
|
|
|
|
I'm invoking depends utility on one of the dll that I have developed and get the following error with a yellow? against the same
Error opening file. The system cannot find the file specified. This Error is coming against the modules MSVCP80D.dll MSVC80P.dll and DWMAPI.dll. What is the implication of this error.
Also the base window shows the following messages
Error: At least one required implicit or forwarded dependency was not found.
Warning: At least one delay-load dependency module was not found.
Error: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
|
|
|
|
|
Your DLL is built with debug libraries. Debug libraries do not exist on a machine, by default.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
I'm learning RPC (remote procedure call).
I included "rpcndr.h", and add "Rpcrt4.lib" in object/library modules. When compiling, I got the following errors:
Linking...
interface_c.obj : error LNK2001: unresolved external symbol _MIDL_user_free@4
interface_c.obj : error LNK2001: unresolved external symbol _MIDL_user_allocate@4
Debug/22_rpc.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
what am I missing? I am using VC6.0.
Thanks a lot for any help!
|
|
|
|
|
According to MSDN: The midl_user_allocate function is a procedure that must be supplied by developers of RPC applications. It allocates memory for the RPC stubs and library routines.
Example:
void __RPC_FAR * __RPC_USER midl_user_allocate(size_t cBytes)
{
return ((void __RPC_FAR *) malloc(cBytes));
} The midl_user_free function also must be written by the developer.
Example:
void __RPC_API midl_user_free(void __RPC_FAR * p)
{
free(p);
} Best wishes,
Hans
|
|
|
|
|
I see why it's called _user_ now. At first I thought it's my RpcRt4.lib which is not up-to-date.
Thank you very much, Hans.
|
|
|
|
|
What is the difference between VirtualAlloc and GlobalAlloc functions which are used to allocate memory from Heap. Also how is the heap management done given that there is no concept of Local and Global Heap.
|
|
|
|
|
|
|
Hello, does anybody ever tried to automate Excel in VC++ and want to show the autofilter programmatically? I tried Range.AutoFilter() function, however, I cannot make it work for me. I just want to get the drop-down arrow show up for me (similar to Data->AutoFilter menu in Excel).
Appreciate if anyone can direct me to a website which has more info on excel related application. Most of the sources I found is using either C# or VB, but limited info on C++.
Thanks a lot!
haiying
|
|
|
|
|
Hi, Can you please that Problem:
Maximum Clique Problem is a graph related NP-Complete problem. A Clique in an undirected graph G is a set of vertices V such that for every vertice pairs in V, there exists an edge connecting the two. Another definition of clique is given as the induced subgraph of V which is a complete graph. Also, Maximum Clique Problem is the corresponding optimization problem that is finding the the largest clique in a graph.
1) Find a subtle way to reduce Clique Problem to the Independent Set problem. (You should give the complexity of the transfer function in the report.)
2) Implement a software to solve the Maximum Clique Problem.
(You should give the complexity in the report.)
3) Implement a software which applies the appropriate transformation you have proposed and solves the problem as an instance of Maximum Independent Set problem.
(You should give the complexity in the report.)
Data and Test Runs:
Your software should be able to process any arbitrary graph which is represented by a NxN matrix in the input text file. A sample text file is provided within this project package (sample.txt). In this file, a value of 1 indicates the existence of an edge between vertex i and j. Your project will be tested both with this file and some other test files.
Kamrul Ahsan
Dept. of Computer Engg.
ITU,
Turkey
|
|
|
|
|
Sure, we'll be glad to help. Post the code you have so far, so we won't waste your time going over stuff you've already done.
|
|
|
|
|
Why does the following code result in a deadlock?
#include <windows.h>
#include <stdio.h>
#include <process.h>
unsigned __stdcall thread(void*)
{
while(1)
{
printf("t");
}
}
int main()
{
unsigned dwThreadId;
HANDLE hThread = (HANDLE) _beginthreadex(NULL, 0, thread, NULL, 0, &dwThreadId);
while(1)
{
SuspendThread(hThread);
printf(".");
ResumeThread(hThread);
}
return 0;
}
|
|
|
|
|
tom groezer wrote: Why does the following code result in a deadlock?
It depends on how ::printf() is implemented.
I assume it uses a critical section at some point to block other threads from messing up the memory while executing. If my assumption is correct, it's just a matter of time before your thread is suspended while inside the critical section and your main thread will be blocked when calling ::printf() resulting in a deadlock.
You should consider suspending a thread from another thread a serious bug since you have no idea in what state the other thread is in. If the thread that is suspended owns a critical section it may not be released and you'll get deadlocks.
Read this excellent article[^] to learn the basics of multithreading and to avoid common pitfalls.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
The handle must have the THREAD_SUSPEND_RESUME access right.
|
|
|
|