|
I am rewriting an old application in VS2010 that was developed in vc++6.0. I am trying to keep the basic structure of the GUI the same which consists of a main Dialog in which I have multiple child dialogs. All the child dialogs except one are simple with no border, title bar or system menu. This works fine in VC++6.0, but on VS2010, none of the controls that I have in those child dialogs show up when I run the program.
Am I missing something simple here that I am not aware of?
thanks
PKNT
|
|
|
|
|
Kiran Satish wrote: Am I missing something simple Yes, some more detail. Is this MFC or basic Win32? How are the dialogs created, how are they displayed? etc.
|
|
|
|
|
Its a MFC dialog based application. Main dialog is created when the application is created using "New Project" wizard and the child dialog is created by inserting a "Insert Dialog" in resource view and then adding dialog controls to it.
PKNT
|
|
|
|
|
Did you remember to include your dialog template resources in the build? The code will (probably) compile happily without them, but fail to initialize the dialog controls.
|
|
|
|
|
Which could be the reason why a tooltip is layered behind the dialog ?
Here is the implementation:
class CNotifyDlg : public CAlertDialog
{
CToolTipCtrl m_ToolTip;
}
and
BOOL CNotifyDlg::PreTranslateMessage(MSG* pMsg)
{
switch(pMsg->message)
{
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MOUSEMOVE:
m_ToolTip.RelayEvent(pMsg);
}
return CAlertDialog::PreTranslateMessage(pMsg);
}
BOOL CNotifyDlg::OnInitDialog()
{
CAlertDialog::OnInitDialog();
m_ToolTip.Create(this);
m_ToolTip.AddTool(GetDlgItem(IDCANCEL), _T("My message"));
m_ToolTip.Activate(TRUE);
return TRUE;
}
LRESULT CNotifyDlg::OnButtonMouseOver(WPARAM wParam, LPARAM lParam)
{
if(m_btnClose.GetDlgCtrlID() == (int)wParam)
m_ToolTip.UpdateTipText(_T("My message again"), GetDlgItem(IDCANCEL));
m_ToolTip.Update();
return 0;
}
and I see the tooltip window, but is just behind the dialog ... I can not figure out why is happen this ...
CAlertDialog is derived from CDialog ... what I have done wrong here ? Could you help me ?
Thank you.
|
|
|
|
|
Has your dialog the top most status (e.g. by calling SetWindowPos with HWND_TOPMOST or setting the WS_EX_TOPMOST style)?
Then change that.
|
|
|
|
|
The only call with SetWindowPos is
SetWindowPos(
FindWindow(_T("Shell_TrayWnd"), _T("")),
m_nStartPosX,
m_nStartPosY,
rc.Width(),
rc.Height(),
SWP_NOOWNERZORDER | SWP_NOACTIVATE);
inside of CAlertDialog ... I don't think this call is the issue ...
|
|
|
|
|
But you gave an idea:
m_ToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);
m_ToolTip.AddTool(GetDlgItem(IDCANCEL), _T("Bla bla bla"));
m_ToolTip.Activate(TRUE);
m_ToolTip.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE);
I don't know if it's all right, but seem to work ... Thank you !!!
|
|
|
|
|
I was just going to suggest removing SWP_NOOWNERZORDER .
However, fine to hear that it seems to be solved.
|
|
|
|
|
Still, I will try your suggestion ... I'll come back.
|
|
|
|
|
Yep, I removed SWP_NOOWNERZORDER flag, and everything seem to be all right now, without m_ToolTip.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE); ... so, it is better solution ! Thank you again ! 
|
|
|
|
|
Hi Johen. After all, I can not give up SWP_NOOWNERZORDER flag ... It should be there, but I want to ask you what is the best solution to put tooltip above CDialog which has SWP_NOOWNERZORDER flag:
SetWindowPos(
FindWindow(_T("Shell_TrayWnd"), _T("")),
m_nStartPosX,
m_nStartPosY,
rc.Width(),
rc.Height(),
SWP_NOOWNERZORDER | SWP_NOACTIVATE);
the solution was the following:
BOOL CNotifyDlg::OnInitDialog()
{
CAlertDialog::OnInitDialog();
m_ToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);
m_ToolTip.AddTool(GetDlgItem(IDCANCEL), _T("Close this notification"));
m_ToolTip.Activate(TRUE);
m_ToolTip.SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOOWNERZORDER | SWP_NOSIZE);
return TRUE;
}
It is ok ? To be frank, I don't like idea to setup tooltip as top level window ... there is another solution ?
Flaviu.
|
|
|
|
|
A tooltip should be a top level window to ensure that it is visible. It is only shown when requested by the user and closed when clicking anywhere with the mouse. So it does not interfere with other GUI elements. If you have a working solution I would stay with that.
|
|
|
|
|
Ok, I will. It is always a pleasure to talk with you. Thank you for sharing your experience !
|
|
|
|
|
I really do not know where to post this and I hope I can explain my question , so be gentle.
I am using SAM3x8e hardware timer (TC3) as an interrupt.
The “TC3_Handler” (callback?) global function name is “hardcoded” somewhere and fires as expected at desired intervals.
I do some verification of this by outputting simple message to LCD.
The LCD “class” is declared / instantiated as a global class to the entire application and works amicably.
Simple “lcd.print(“OK”)” is executed just fine in the TC3 handler.
I also do some hardware output – turn on / off LED – just for an additional indication the handler is being executed.
Now I want to execute a method / function of ANOTHER globally defined / instantiated class, again in same TC3 handler.
Adding cpal.Run(); did not compile – undefined “cpal”.
I had to ADD extern CPAL cpal; so it would compile and execute cpal.Run();
My question is
both LCD and CPAL classes are global, the LCD can be used OK, but the CPAL has to have the extern “reference” added into the TC3 handler. Why?
Thanks for reading, appreciate any help.
Cheers
Vaclav
|
|
|
|
|
Probably because LCD global object is declared extern in one of the headers included by your source file containing the TC3 handler.
|
|
|
|
|
Thanks,
makes perfect sense.
I am not sure I'll spent time to actually look for such declaration, but I need to learn more about hardware interrupts so maybe I'll run into it sooner or later.
Thanks again.
Vaclav
|
|
|
|
|
|
I need opinions on code like this:
"if ((++(m_pLF->m_iLogCnt)) >= MSG_QUEUE_FILE_SIZE)"
maybe it's just me and my past - I was taught never to depend on order of operations. This is handled with the parenthesis , but really, should it be that hard to analyze an IF statement?
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
That's not terribly complex, but did you really need it that way?
|
|
|
|
|
No, that one was not terribly complex, and I also selectively edited it.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Obfuscation is the best way to annoy those who have to maintain your code.
|
|
|
|
|
You know, it's one thing to obfuscate, it's another to code in such a style as approaching enemy action. It's hard enough to write clear code. The style of code I posted just seems easy to break and difficult to debug. The debugger is going to treat that like one line of code.
Caveat: I freely admit that I choose to restrict how much code I put on a line. I like using ternary or conditional operator as it can make things much cleaner, as long as you don't get silly with it.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Absolutely agree with you. Most of the time code like that is done by people who don't know any better (copied it from the internet), or who think they are so damn clever.
|
|
|
|
|
Well, I know who wrote the code - I'll go with clever. Bright individual, I just wanted to make sure it wasn't just me.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|