|
When you run this code what happen?
void CDialogDlg::SetToolTip(LPCTSTR Text,HWND hwnd)
{
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.lpszText = (LPTSTR)Text;
ti.hinst = AfxGetInstanceHandle();
ti.hwnd = hwnd;
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
ti.uId = (UINT) hwnd;
m_tooltip.SendMessage(TTM_ADDTOOL, 0, (LPARAM) &ti);
}
void CDialogDlg::OnBnClickedCancel()
{
m_tooltip.Create(this);
m_Button.ModifyStyle(BS_BITMAP,BS_ICON);
m_Button.SetIcon(LoadIcon(AfxGetApp()->m_hInstance,(LPCTSTR)IDI_UP));
SetToolTip("Test",m_Button.m_hWnd);
}
|
|
|
|
|
The image on the button disappears when I click on the Cancel button for the first time and is not displayed again. The application crashes when I click on Cancel button for the second time (but this can be handled)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Yeah you got an error because you have this function on the cancel m_tooltip.Create(this); you must remove this function of Oncancel I tried to work with this code and it worked and I could see image on the button before and after click.
|
|
|
|
|
Do we have a substitute for PreTranslateMessage in Modeless dialog. I guess I have figured the problem and now I need a substitute...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I need to load 2 bitmaps alternatively on the arrow mark of the combo contol(owner draw combo cotrol). This process should take place continuously so that the arrow mark looks as if it is blinking.
if have done this by using a timer which calls the code every second. But after some time the application is being CRASHED.
The code i have used is ,
if(variable == TRUE)
{
m_ctlMode.SetBitmap(IDB_BITMAP_COMBO);
variable = FALSE;
}
else
{
m_ctlMode.SetBitmap(IDB_BITMAP_RED);
variable = TRUE;
}
m_ctlMode.Invalidate(TRUE);
Here m_ctlMode is the control variable of the combo box.
Please can anyone say me how to come out of this problem
Naveen
|
|
|
|
|
Does it crash in debug mode? After which line? Does it work for a long time? In your owner draw function, or in the windows one?
Does your SetBitmap function have a memory leak? A resource leak?
You need to hunt for a few more clues to give us than "it crashes"...
Iain.
|
|
|
|
|
The Application is executing for almost 45 minutes and then its getting crashed. I am not aware of memory leak, resource leak of SetBitmap function . I have kept the code in OnTimer function which calls for every 0.5 second . Can u say me how to find the Memory leak or resource leak of the SetBitmap function.
|
|
|
|
|
1/ If you reply to your original message instead of my reply, I don't get notified that you replied. Strangely enough, I don't spend my time refreshing this page. Shocking, I know...
2/ You haven't answered my question about *where* your program is crashing. If it doesn't crash when compliled with debug symbols, that's a clue. If you can't be bothered to run the program from the IDE so you see the crash, then its going to be too hard to help you.
3/ Try commenting out the lines that actually change the bitmap, and just Invalidate the control. Does it still crash?
4/ Speed up the timer, so the error happens faster - probably
5/ You can see memory use by using task manager. Does the working set slowly increase?
6/ My prime suspect is still resources. For that you need to be highly paranoid about matching up every LoadImage with a DeleteObject call. Do you create fonts in your owner draw routine, but don;'t tidy up? Etc. Nobody here can help you with that, you'll just have to remove chunks of code, and slowly add them back and go over them with a fine tooth comb.
I hope that helped a bit,
Iain.
|
|
|
|
|
Dear Clarke,
I have executed in the following ways.
1. when i have tried with loading only 1 bitmap and invalidating the same there is now change and application got crashed.
2. I have used DeleteItem before loading the bitmaps. But there is no use.
3. When i have speed up the Timer its crashing fast when compared to before.
when timer is called at 500msec --- crashed after 40 min
when timer is called at 50msec --- crashed after 4 min
4. I have seen the memory use in the task manager but there is no increase in it.
5 I have used these commands for invalidating a. Invalidate
b. RedrawWIndow
c. ValidateRgn etc.
but there is no use.
6. I have Executed in Debug mode and the control is always going to OnCtlColor.
I am suspecting that it is due to continuous loading of bitmaps on the same control. Please reply me regarding this .
|
|
|
|
|
Then you already have 90% of the answer...
My guess is that you're creating a new brush every time the OnCtlColor function is called. In the MSDN article for the same thing, it returns the same handle all the time - WM_CTLCOLOR does not delete the handle after it's used.
From MSDN page:
HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)
{
pDC->SetTextColor(RGB(255, 0, 0));
pDC->SetBkMode(TRANSPARENT);
hbr = m_brush;
}
return hbr;
}
I'd make sure that you are not creating the brush each time (the example returns m_hBrush . Remove almost all your code to just making the things (eg)purple, then build up and see where things fail.
Iain.
|
|
|
|
|
Maybe this answer has already been given...
I can't find any SetBitmap() method that takes an ID as a parameter but it makes it look
like you're loading a new bitmap resource every time, without freeing the previous loaded bitmap.
How about loading the two bitmaps in advance (only ONCE) and set those bitmaps in response to
the timer event?
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi,
I tried below code to visible tree control item; I have derived my class from CTreeCtrl.
if (stricmp(SelectStr.c_str(), CompareStr.c_str()) == 0) {
SelectItem(hItem);
EnsureVisible(hItem);
}
In spite of the code calling EnsureVisible on the tree ctrl, the selected node remains hidden under the horz. Scrollbar. You have to click the down arrow on the vert. scrollbar exactly once to see the (pre)selection.
This problem is only when I have horz. Scrollbar on my tree control.
Even I tried this one also,
//HTREEITEM htreeItm = GetFirstVisibleItem();
//if( EnsureVisible(htreeItm)){
// int cool = 0;
// cool = 1;
//}
But it’s returns false when I have horz. Scrollbar.
Can anybody please help me?
Thanks,
Rakesh.
|
|
|
|
|
Hello,
My application is pretty heavy.
It takes about 10 seconds until it's shown to the user, until then, the user don't see a thing.
I want to change the cursor to hourglass before the window is shown.
BTW, my window is created, I just don't show it, until all its components are loaded.
How can I implement this?
I tried to use SetCursor, but when I move my mouse over the background windows it changes back to arrow right away.
Thanks,
Meni.
|
|
|
|
|
If you are using MFC, create a CWaitCursor object, it will manage the hour glass as long as the object is instantiated.
<br />
{<br />
CWaitCursor waitCursor;<br />
<some lengthy operation><br />
}<br />
Change of fashion is the tax levied by the industry of the poor on the vanity of the rich
Fold with us! ¤ flickr
|
|
|
|
|
Sorry, it doesn't help.
I'm not using MFC. I'm using win32...
|
|
|
|
|
|
The problem is that: when the window is still invisible and I set the cursor to hourglass, even if i'll alter the WM_SETCURSOR handling it won't solve it, because my window doesn't get the WM_SETCURSOR messages, because the mouse is over other windows!
How can I implement it, so no matter where my cursor is, it'll show an hourglass cursor.
Thanks you.
|
|
|
|
|
Hi,
I guess your Application Window is not shown till all of the component get loaded.
setCursor has effect for the window only, since the window is not actually shown, set cursor won't have effect.
I think typically scenarios are handled by "Splash Screens". A simple window, its sole purpose is to give the user a feel that application has started and also it can show the progress of loading. Try Something like splash screens.
Best Regards
Raj
|
|
|
|
|
Before going to splash screen strategy, where did you find that icons are applied on windows only? Can you please send a link?
How about lets say capturing the mouse (or something) and then set the icon?
|
|
|
|
|
That doesn't really need a link - its pretty obvious in today's forced multi tasking environment. The window the mouse is over gets the WM_SETCURSOR messages.
The only way to do your plan is to create a transparent window covering up the whole desktop (which can be a headache on a multimonitor system), or just simply do a splash screen.
The splash screen has the advantage of being able to display some sort of progress as your application initialises bit-by-bit.
Iain.
|
|
|
|
|
Hi,
Please search for links.
Simply think can you set cursor for non window application application.
Mouse capture is released when the user explicitly switched to next application(for eg: pressing WINDOWS key, Alt + tab), this can happen as your application is not started in 10 seconds.
|
|
|
|
|
use 'BeginWaitCursor()'and 'EndWaitCursor()'
between these two function calls write ur body of the function.
the moment it calls the BeginWaitCursor() arrow cursor will change into hour glass and when it reaches EndWaitCursor() hour glass will change into arrow cursor.
for ex:
void C01Dlg::OnRelay()
{
BeginWaitCursor();
//
//your function body
//
//
EndWaitCursor();
}
wherever you move ur mouse pointer it will be a hour glass only..
try it out.
ok..
bye.
-- modified at 7:48 Tuesday 26th June, 2007
regards
sudhakar
|
|
|
|
|
Can anyone point me to a good resource that explains - in some detail - all the project settings and the like in Visual Studio (both VC6 and VS2005).
t.i.a
Lee
|
|
|
|
|
Look in MSDN[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
MSDN ?
Are you able to use it to find usefull information on it ?
|
|
|
|