Tooltip disappears too fast in layered window

Win32 Programming

    Next

  • 1. get screenshot of invisible desktop
    How to draw entire desktop into bitmap, even if it's not the active one? I tried PrintWindow(GetDesktopWindow(),...) but it fails for some reason for desktop window (I'm using XP SP2)
  • 2. Confused about return values for some window messages
    The windowsx.h message crackers for the following messages returns zero. However, MSDN says to return TRUE. WM_COPYDATA WM_DELETEITEM WM_DRAWITEM WM_MEASUREITEM WM_UNDO The windowsx.h message crackers for this message returns a BOOL but MSDN says if you handle this message, you should return zero: WM_WINDOWPOSCHANGING MSDN says if you handle this message, you should return TRUE, but what difference does it make? WM_SIZING I have a feeling for the WM_WINDOWPOSCHANGING message, MSDN is right and windowsx.h is wrong. I'm thinking that for the WM_SIZING message, MSDN is wrong. It doesn't seem to make a difference what you return. For the first 5 messages, I'm not really sure. Can someone please comment on these messages and give me the correct return values for them and why? Thanks, Jack
  • 3. Chevron support in a IDeskband toolbar
    Hi, I have a toolbar which needs Chevron support. The toolbar is not implemented as a rebar control but rather its an IDeskBand toolbar. I have set the flag DBIMF_USECHEVRON in IDeskBand::GetBandInfo() and I DO get to see the chevron and the corresponding drop menu when the chevron is clicked. However, my toolbar buttons are created using custom painting (NM_CUSTOMDRAW) and in the chevron drop menu only the text is coming. I need to understand which messages to catch when the chevron drop menu is being drawn so that I can render the same look and feel to them. Also, how do I handle the menu messages (e.g. when user hovers the first row or the second row in the chevron drop down menu.) Please help, I am really stuck here - Vivek
  • 4. SBM_SETSCROLLINFO vs. SetScrollInfo
    Hi, I wanted to know why it is not correct to use SBM_SETSCROLLINFO (at least that's what the Microsoft documentation says). The reason why I'm using it is because in some cases (during a resizing, i.e. WM_SIZE message being processed) it refuses to do anything and does not send the SBM_SETSCROLLINFO message, but if I delay the call to do it after all the WM_SIZE messages have been processed (i.e. on idle) then it works. Thanks, MAnu

Tooltip disappears too fast in layered window

Postby David Ching » Mon, 05 Sep 2005 08:57:32 GMT

Hello,

I have a (MFC) layered window that I create like this:

DWORD dwExStyle = 0;

#ifdef USE_LAYERED_WINDOWS
    dwExStyle |= WS_EX_LAYERED;
#endif

    BOOL bOK = CreateEx (   dwExStyle,
                        AfxRegisterWndClass (0, NULL, NULL, 
AfxGetApp()->LoadIcon (IDR_MAINFRAME)),
                        _T("Window caption"), WS_POPUP | WS_SYSMENU, rect, 
NULL, 0 );

    if (!bOK)
        return FALSE;

#ifdef USE_LAYERED_WINDOWS
        SetLayeredWindowAttributes  ( GetSafeHwnd(),  RGB(255,255,0),  255, 
LWA_COLORKEY) ;
#endif


Whether the window is layered or not depends on whether USE_LAYERED_WINDOWS 
is defined.

After the window is created, I create a child listview control (MFC 
CListCtrl class), in Report view.  It has the LVS_EX_LABELTIP style so that 
the tooltip should appear if the mouse is hovered over a subitem that is 
truncated.  This works fine if USE_LAYERED_WINDOWS above is not defined 
(i.e. the window is not layered).  But if it is defined, then the tooltip 
appears briefly, but disappears about 0.1 seconds later! The only time it 
displays normally is if I hover over the first (leftmost) pixel of the text, 
or if I hover over the icon in the first column.

What could be causing the tooltip to disappear?  I know layered windows work 
by using off-screen DC's.  Do tooltips also do this also?

Thanks for any help.  I'm very perplexed.

-- David



Re: Tooltip disappears too fast in layered window

Postby Kellie Fitton » Tue, 06 Sep 2005 04:09:15 GMT

Hi,

Well, if USE_LAYERED_WINDOWS is defined, then dwExStyle should
equals the window style WS_EX_LAYERED, otherWise dwExStyle will
have a zero value initialize. Also, you could create the layered
window directly withOut the conditional text (#ifdef....#endif),
especially if you want to create a layered window, try this:

	CreateWindowEx(WS_EX_LAYERED, .............);
	UpdateLayeredWindow()

According to microSoft, when creating a layered window, it is more
efficient to use the API UpdateLayeredWindow(), especailly since the
API SetWindowLayeredAttributes() uses more memory for its reDirection
handling of a layered window, which tends to have a delay factor.

 http://www.**--****.com/ 

Hope these information helps,

Kellie.


Re: Tooltip disappears too fast in layered window

Postby David Ching » Tue, 06 Sep 2005 04:28:20 GMT






Thanks Kellie.  The USE_LAYERED_WINDOWS was a quick way of flipping the 
layered window style on and off to illustrate the problem only occurs with 
it turned on.



I'd love to use UpdateLayeredWindow(), especially since it supports 
per-pixel alpha transparency, and SetLayeredWindowAttributes() doesn't.  The 
trouble is, UpdateLayeredWindow() doesn't support the window having child 
windows in it.  The child windows aren't painted at all if you use 
UpdateLayeredWindow().  So if you want a layered window with child controls, 
you have no choice but to use SetLayeredwindowAttributes().

-- David



Similar Threads:

1.Tooltip disappears too fast in layered window

"Kellie Fitton" < XXXX@XXXXX.COM > wrote in message 
news: XXXX@XXXXX.COM ...
> Hi,
>
> Well, if USE_LAYERED_WINDOWS is defined, then dwExStyle should
> equals the window style WS_EX_LAYERED, otherWise dwExStyle will
> have a zero value initialize. Also, you could create the layered
> window directly withOut the conditional text (#ifdef....#endif),
> especially if you want to create a layered window, try this:
>
> CreateWindowEx(WS_EX_LAYERED, .............);
> UpdateLayeredWindow()
>

Thanks Kellie.  The USE_LAYERED_WINDOWS was a quick way of flipping the 
layered window style on and off to illustrate the problem only occurs with 
it turned on.


> According to microSoft, when creating a layered window, it is more
> efficient to use the API UpdateLayeredWindow(), especailly since the
> API SetWindowLayeredAttributes() uses more memory for its reDirection
> handling of a layered window, which tends to have a delay factor.
>

I'd love to use UpdateLayeredWindow(), especially since it supports 
per-pixel alpha transparency, and SetLayeredWindowAttributes() doesn't.  The 
trouble is, UpdateLayeredWindow() doesn't support the window having child 
windows in it.  The child windows aren't painted at all if you use 
UpdateLayeredWindow().  So if you want a layered window with child controls, 
you have no choice but to use SetLayeredwindowAttributes().

-- David


2.Tooltip on Combobox disappears - Windows Forms bug?

	I am using .NET 2.0 forms and running on Windows XP SP2.  When I have a 
tooltip on a combo box, and the combo box is expanded (ropped down 
using the arrow, it will no longer display it tooltip, no matter how 
long I hover.  Even if I move off the control and back it will still not 
display its tooltip.  If I then go to another control that has tootips, 
then back to the combobox, it will again display its tooltip, until the 
next time it is expanded.
	
	Below is a small sample that has this bug (on my machine anyway.) It is 
simply the standard VS8.0 generated code, condensed. Strangely, if I 
remove the EnableVisualStyles() line, then the tootips seem to work 
correctly.

	I could not find any information about this bug.  I am curious if 
anyone else has come across it, and if there is a solution?  Any help 
appreciated.


======= Buildable Code Sample Below

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace ComboTest
{
     static class Program
     {
         [STAThread]
         static void Main()
         {
             Application.EnableVisualStyles();
             Application.Run(new Form1());
         }
     }

     class Form1 : Form
     {
         public Form1()
         {
             InitializeComponent();
         }

         private System.ComponentModel.IContainer components = null;
         protected override void Dispose(bool disposing)
         {
             if (disposing && (components != null))
             {
                 components.Dispose();
             }
             base.Dispose(disposing);
         }

         private void InitializeComponent()
         {
             this.components = new System.ComponentModel.Container();
             this.comboBox1 = new System.Windows.Forms.ComboBox();
             this.toolTip1 = new 
System.Windows.Forms.ToolTip(this.components);
             this.button1 = new System.Windows.Forms.Button();
             this.SuspendLayout();
             // comboBox1
             this.comboBox1.DropDownStyle = 
System.Windows.Forms.ComboBoxStyle.DropDownList;
             this.comboBox1.FormattingEnabled = true;
             this.comboBox1.Location = new System.Drawing.Point(12, 59);
             this.comboBox1.Name = "comboBox1";
             this.comboBox1.Size = new System.Drawing.Size(121, 21);
             this.comboBox1.TabIndex = 0;
             this.toolTip1.SetToolTip(this.comboBox1, "Combo Tooltip");
             // button1
             this.button1.Location = new System.Drawing.Point(12, 12);
             this.button1.Name = "button1";
             this.button1.Size = new System.Drawing.Size(75, 23);
             this.button1.TabIndex = 1;
             this.button1.Text = "button1";
             this.toolTip1.SetToolTip(this.button1, "Button tip.");
             this.button1.UseVisualStyleBackColor = true;
             // Form1
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(292, 266);
             this.Controls.Add(this.button1);
             this.Controls.Add(this.comboBox1);
             this.Name = "Form1";
             this.Text = "Form1";
             this.ResumeLayout(false);
         }
         private System.Windows.Forms.ComboBox comboBox1;
         private System.Windows.Forms.ToolTip toolTip1;
         private System.Windows.Forms.Button button1;
	}
}


====== END Code Sample





Return to Win32 Programming

 

Who is online

Users browsing this forum: No registered users and 64 guest