|
Hi
I need to popup a menu after I click a button on a toolbar. How can I find the position of the button?
Thanks
|
|
|
|
|
CToolBar::GetItemRect(). Use CToolBar::CommandToIndex to get the index if you have just the command ID.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
hi,
I want to change the Color of Scroll Bars which are appeared with Edit Controls(Text Boxes)..
please reply me if any body know it
Thanks in advance..
|
|
|
|
|
Hi I'm getting an unhandled exception in MSVCRTD.DLL Stack Overflow.
Basically I can't see where it's coming from. The below try block call's itself recursively and doing some other stuff along the way until a global count has been reached.
The only exception i can trap is the catch all. Is there anyway of determining the type of exception? I can't work out where it is being thrown from?
code:
try
{
AddNextCallToPlayList();
}
catch( CMemoryException* e )
{
LOG_ERROR(_T("CMem\n"));
// Handle the out-of-memory exception here.
}
catch( CFileException* e )
{
// Handle the file exceptions here.
LOG_ERROR(_T("CFile\n"));
}
catch( CException* e )
{
// Handle all other types of exceptions here.
LOG_ERROR(_T("CException \n"));
}
catch(_com_error e)
{
LOG_ERROR(_T("catch com\n"));
}
catch(...) //__except(EXCEPTION_EXECUTE_HANDLER)
{
LOG_ERROR(_T("catch all\n"));
}
|
|
|
|
|
Either remove the catchall or set stack overflow exceptions to break into the debugger. Then you can look at the call stack.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
The problem is that it runs through this code at least 137 times without causing a problem. If i remove the catch all the stack is showing the current function but no where near anything that could cause a problem.
How do i set set stack overflow exceptions?
Your comments are appreciated
Carl
|
|
|
|
|
crandall wrote:
The problem is that it runs through this code at least 137 times without causing a problem.
It sounds like the stack overflow is being caused by unbounded recursion. Check to see if this function can be called recursively somehow, and if it is, make sure it doesn't get called too many times.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
It is being called recursively. How can i achieve this successfully?
Carl
|
|
|
|
|
You need to include some code to prevent the recursion from going too deep; you need to reduce the number of times the function is called recursively. How you do this is up to you, but you may need to convert the algorithm to an iterative one. If you can limit the depth of the recursion without ruining the algorithm then that would be the best option.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi...
How can I simulate pressing the tab key with enter key. I have 5 edit controls in my view and I want to jump to the next edit control not by pressing the tab key but by pressing the enter key. I tried like this
BOOL CMyView::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->wParam == VK_RETURN)
{
PostMessage(WM_KEYDOWN, VK_TAB, NULL); UpdateCalc();
return 0;
}//if
return CFormView::PreTranslateMessage(pMsg);
}
this works exept, that this code simulate's a double key press of the tab key.
Please Help!
Thanks
My question is:
|
|
|
|
|
|
this works but still the code executes 2 times. Let's say that my position is on the first edit ctrl. When I press the enter key for the first time this segment of code is executed:
if(pMsg->wParam == VK_RETURN)
{
PostMessage(WM_NEXTDLGCTL); //the first time
UpdateCalc();
return false;
}//if
But after that the focus goes to the next edit ctrl?????
|
|
|
|
|
i think this could be done without simulating any keystrokes using SetFocus(...) and GetNextWindow(...) functions
|
|
|
|
|
Try to use the following code instead:
BOOL CMyView::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam==VK_RETURN)
{
pMsg->wParam=VK_TAB;
}
}
return CFormView::PreTranslateMessage(pMsg);
}
Lisoft
|
|
|
|
|
Thanks. I'm sure this will help.
|
|
|
|
|
If you return TRUE instead of 0 from this method
then the initial return key should not get processed further?
|
|
|
|
|
Hi
I have a dialog which I want to be able to have detect a user clicking on and off the title bar. I can detect the left button down on the title bar by implementing CDialog::OnNcLButtonDown() which corresponds to ON_WM_NCLBUTTONDOWN() . Now what I want is to detect the left button being released. I've tried CDialog::OnLButtonUp() which corresponds to ON_WM_LBUTTONUP() and of course CDialog::OnNcLButtonUp() which corresponds to ON_WM_NCLBUTTONUP() but they do not seem to get called (I make an AfxMessageBox() call in them to check). I can get CDialog::OnNcLButtonUp() to be called by double-clicking the title bar but not when just releasing the mouse button. Can anyone help with this?
Thanks
|
|
|
|
|
Aside: You may want to replace the AfxMessageBox() call with TRACE() , since the former causes a change in focus.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
This behaviour is caused by the default processing of the WM_NCLBUTTONDOWN message. When it processes this message, it enters a loop whereby it moves the dialog if the mouse moves, and exits the loop when it receives a WM_NCLBUTTONUP message. The fix is to not call the default processing for WM_NCLBUTTONDOWN . The problem then is that the user cannot move the dialog, so you'll have to implement the code for moving the dialog yourself.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Your dialog should get a WM_MOVE message after the window has been moved (and WM_MOVING messages while
it's dragged).
Wouldn't that be enough ?
|
|
|
|
|
Hello !
I use the function CreateFile to open a COM port. Everything works fine unless the port number is only 1 digit (up to port 9). When I try top open the COM port10, the function returns INVALID_HANDLE_VALUE and a call to getLastError() gives me ERROR_FILE_NOT_FOUND (2).
Here is the code:
hCom = CreateFile(pszPortName,<br />
GENERIC_READ | GENERIC_WRITE,<br />
0, <br />
NULL, <br />
OPEN_EXISTING, <br />
0, <br />
NULL <br />
);<br />
What is the problem ??
|
|
|
|
|
For COM ports over COM9, you have to use the UNC notation, ie. COM10 = "\\.\COM10". This is only available for a NT-based OS, so it won't work on Win95/98/ME. Using this method, you can access up to COM255.
Remember if you're hardcoding the string it will need to be "\\\\.\\COM10" because of the character substitution.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
All,
I have tried a number of methods found here to get tool tips to work on my dialog button controls and have settled on using the method found in an article found here by Jean-Louis Guenego. All, including the method Jean-Louis employs, work great on Modal dialogs, but a soon as I try to use the exact same code in a Modaless dialog, the tool tips do not work. Jean-Louis Guenego's project also allows the placement of a bitmap on buttons and that part works fine on both modal and modaless dialogs.
I am using this code to create the dialog...
if (m_pSMDlg == NULL)
{
m_pSMDlg = new CFileDlg(TRUE,sDir,sExt,NULL);
if (m_pSMDlg->Create(MAKEINTRESOURCE(IDD_FILEDLG), NULL) == TRUE)
{
}
}
Is there something in the creation of my dialog I can do to allow tool tips to work?
Thanks,
Hal Roenick
|
|
|
|
|
If you read the message board below the article you referenced you would see that the same question was asked and answered there. http://www.codeproject.com/buttonctrl/tooltipressourcebutton.asp#xx653091xx[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
PJ,
I went and read what you suggested and had read that method many times before and it does not seem to work. The problem is that while I have the "ON_NOTIFY_EX(TTN_NEEDTEXT, 0, )
" in my message map, the "OnToolTipNotify" message is never sent by my buttons!
I have added all the code suggested for this method, but after doing so, I have placed a breakpoint withing the "OnToolTipNotify" message handler for my dialog and it never gets hit. The only thing I have been able to find that might be a clue is that because these buttons are set to "owner draw" (due to a bitmap being placed on them) there is a "notify" property that becomes disbled. I cannot figure out why my buttons do not send the "ON_NOTIFY" message when they are approached by the mouse.
Any thoughts?
Thank you,
Hal Roenick
|
|
|
|