Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

TyrionTheImp

@TyrionTheImp
About
Posts
28
Topics
13
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Simple API to record AVI Files
    T TyrionTheImp

    Hi All, Is there a simple C# Dot Net API available to record AVI files for a given set of BMP images ? Would appreciate any code samples that shows the usage of such an API ! Thanks In Advance !

    C# csharp json question

  • MouseDown event missed in custom Button class
    T TyrionTheImp

    Hi All, Am facing an issue with getting the MouseDown event for a custom drawn Button class in Dot Net 2.0 framework. This custom class basically listens to the MosueDown,Up,Hover,Enter and Leave events and updates the image shown on it (if we hover or click, an "active/pressed" image is shown else "inactive" image is painted).The code is as below :

    class CustomButton : Button
    {
    Bitmap displayimage;
    bool down;
    public CustomButton()
    {
    MouseUp += OnMouseUp
    MouseDown += OnMouseDown //etc.. for other mouse events
    }

    private void OnMouseDown(object sender, MouseEventArgs e)
    {
    down = true;
    displayimage = new Bitmap("pressedimage.png");
    Invalidate();
    }

    private void OnMouseUp(object sender, MouseEventArgs e)
    {
    down = false;
    displayimage = new Bitmap("inactiveimage.png");
    Invalidate();
    }

    protected override void OnPaint(PaintEventArgs e)
    {
    if (down)
    {
    Matrix matrix = new Matrix();
    matrix.Translate(1, 1, MatrixOrder.Prepend);
    e.Graphics.Transform = matrix;
    }
    e.Graphics.DrawImage(bitmapImage);
    e.Graphics.DrawString(displaystring);
    base.OnPaint(e);
    }
    }

    The buttons are created in the main Form class and we also listen to MouseDown event here :

    class WinForm1 : Form
    {
    CustomImageButton button = new CustomImageButton ();

    public WinForm1
    {
    button.MouseDown += OnButtonMosueDown;
    }

    private void OnButtonMosueDown(object sender, MouseEventArgs e)
    {
    //take some action , log the user click action
    }
    }

    The problem is MouseDown events don`t even get trigerred sporadically, mostly seen in cases where the user is working with some external application and then directly comes over and clicks the custom button on the UI. Any idea as to what could be the cause/likely solution ? Is this related to the click through issue seen in dot net 2.0 Toolstrip class (refer http://blogs.msdn.com/b/rickbrew/archive/2006/01/09/511003.aspx ) ?

    Windows Forms graphics help com design question

  • Form MouseLeave event [modified]
    T TyrionTheImp

    Hey Ravi, Thanks for the reply - will try it in combination with the code suggested by Rob earlier.

    .NET (Core and Framework) question csharp winforms com help

  • Form MouseLeave event [modified]
    T TyrionTheImp

    Hi Rob, Yes Deactivated would work when the user actually activates another window thus deactivates my window. However, the behavior i`ve described does not really seem unusual - for example if the user is working with my application - and the mouse enters/leaves the child windows and the parent window , then certain parts of the UI are highlighted accordingly - thus reducing user confusion :)

    .NET (Core and Framework) question csharp winforms com help

  • Form MouseLeave event [modified]
    T TyrionTheImp

    Hey Luc, Regarding the context menus and tool strip/main menus we can listen to their Activated events, so i don`t think that should be an issue :) The tricky part is to differentiate between my applications client area and other windows that may be place directly above it. In that case, MosueLeave gets fired and the even if the user hovers over the other window, the Cursor is still within the client area boundaries ! One would expect WinForms to provide some notifications for such a basic event but i haven`t (yet) found anything helpful in the Win32 API layer as well.

    .NET (Core and Framework) question csharp winforms com help

  • Form MouseLeave event [modified]
    T TyrionTheImp

    Hi Rob, Thanks for the code snippet - it works perfectly when the mouse leaves the ChildForm and moves into the ParentForm ! Howeverm for the second casse i mentioned - "some other external application (say Task Manager with always on top as true) is positioned exactly above the child form and is clicked" , the Mouse Leave event on the ChildForm is not triggered. Is there some other event i need to be listening to for this ?

    .NET (Core and Framework) question csharp winforms com help

  • Form MouseLeave event [modified]
    T TyrionTheImp

    Hi All, I have 2 main Form classes - ParentForm and ChildForm in the same exe. ChildForm has a bunch of numeric up-down controls on it. I create an instance of ChildForm, set TopLevel = true and do SetParent with the ParentForm as the parent handle (doing this enables the non client area of ChildForm to stay highlighted when its selected). Now the problem is I need to know when the mouse has left the ChildForm entirely. The Leave event for the ChildForm is never fired. If we listen to the MouseLeave event it gets fired if the mouse hovers over any of the numeric controls and also when the mouse goes to the parent form. Is there any way I can differentiate between these 2 cases ? Also note that we need to cover the case where some other external application (say notepad or Task Manager with always on top as true) is positioned exactly above the child form and is clicked EDIT UPDATE : Thanks to all for the replies ! Have asked the same question on the MSDN Forums - http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/51e040a5-77f9-4b43-a462-1b5e3a13b90a/?prof=required[^] TIA

    modified on Monday, April 11, 2011 12:00 PM

    .NET (Core and Framework) question csharp winforms com help

  • Issue with tooltips for custom drawn image buttons
    T TyrionTheImp

    Hi All, Am facing an unusual issue with some bitmaps that i`m loading dynamically. The situation is that i`ve got a button on which I draw a bitmap dynamically depending on whether the mouse has hovered over it, if it was previously clicked etc... A tooltip is associated with this button and has ShowAlways = true. I also set ToolTpActive = false and then true due to this fix suggested for a framework bug (as given at http://209.85.229.132/search?q=cache:nj6GSkFDwuIJ:stackoverflow.com/questions/559707/c-tooltip-will-not-re-appear-after-first-use+tooltip%2Bbug%2Bactive%2Bc%23&cd=3&hl=en&ct=clnk&gl=in ) Now the issue is that sometimes when i`m working with other applications the bitmaps get laoded partially and are clipped from the top (maybe upper 25% of it). My button size is the same and i debugged to see if the bitmap gets loaded correctly, and it does. I`ve seen this happening only with buttons that have a tooltip, and this button class is used in 3 separate processes (running simult.) and all of them get clipped one after another. I tried to comment out the SetToolTipText and ShowAlways parts of the code but it still occurs. Has anyone come across such an issue earlier, that too happening across processes ? Any help is most appreciated. Thanks in advance.

    Windows Forms help com graphics question

  • How to change the forms and dialogs look and feel
    T TyrionTheImp

    yup i agree with hamid, WM_OWNERDRAW gives u full control over the drawing operations. and sorry but i`m not too familiar with the newer Vista and Office 2007 styles

    C / C++ / MFC c++ tutorial question

  • How to change the forms and dialogs look and feel
    T TyrionTheImp

    Hi suthakar, You can call the ModifyStyle or ModifyStyleEx to update ur window styles dynamically. Alternative is to use the SetWindowLong family of functions (as documented in MSDN) to change the style byte values, and update the window accordingly. Just be sure that your style values are compatible with the way ur using ur dialogs/forms.

    C / C++ / MFC c++ tutorial question

  • Parenting a modal CDialog
    T TyrionTheImp

    Hey Guys, Thanks to David`s sample I found a "fix" for this issue... u need to set the owner in the initdialog function and also manage the visibility state urself. This, along with the code to restrict the dialog`s movements makes it feel as though its an actual child window and also keeps DoModal working. Thanks to all for the help. Appreciate it I do.

    C / C++ / MFC database question lounge

  • Parenting a modal CDialog
    T TyrionTheImp

    Hi David, That sample looks interesting....i`ll try tweaking the GetOwner and SetParent part right now :)

    C / C++ / MFC database question lounge

  • Parenting a modal CDialog
    T TyrionTheImp

    Hi Sarath, Ur absolutely right, thats the first thing i tried and it completely hangs the entire application UI itslef

    C / C++ / MFC database question lounge

  • Parenting a modal CDialog
    T TyrionTheImp

    Hi All, I had a general query regarding modal dialogs and child windows. Is there any way by which I can restrict a CDialog instance to be within the client area of a parent window and yet also allow DoModal method to work correctly ? From what i`ve seen so far, such dialogs show the CWnd value passed to them in the constructor as the parent/owner in Spy++ but can still be moved out of it when the modal loop starts. Doing a SetParent causes both the parent and dialog to hang when i call DoModal. Thanks in Advance.

    C / C++ / MFC database question lounge

  • Multiple Context Menu visibility issue
    T TyrionTheImp

    Hi All, Just came across a strange issue recently. Maybe its a bug in the framework or something ? I have 2 processes running , each with its own winform UI, say host application and external application. The host application has a user control and a context menu defined for that user control, plus some blank panels. The external application also has a user control and context menu defined on it. Now lets say do a SetParent across processes(i know, i know but that`s what the applications must do right now), with the host process` panel as the parent handle, and the external application`s user control is made its child window, then the context menu`s show unusual behavior i.e we can have both their context menus visible simultaneously ! I`m using the contextmenustrip class of dot net 2.0 and this issue doesn`t seem to occur for the older 1.1 context menu classes (in the same scenario). Is this a known issue with the newer 2.0 class ? Are there any workarounds to rectify this behavior ? Is there any way I can get to know the context menu started, closed events across processes if required? Any help is most appreciated. Thanks in advance.

    Windows Forms help design question

  • Getting the window handle of Help Windows
    T TyrionTheImp

    Hi all, I had a query regarding the zorder relationships of help windows and chm files. If we use the Help.ShowHelp or Help.ShowHelpIndex methods to load help files in a program, the first paramater can specify the owner control. If this is set to null , then the last active window will automatically be set as the owner. Is there any way to bypass this mechanism and make the help window an unowned top-level window ? Thanks in advance

    Windows Forms database help question

  • Making FileDialogs as Child Windows
    T TyrionTheImp

    Hi Joe, Yes i`m familiar with Win32 API .Can u tell me how using HookProcs and WndProcs will help ?

    Windows Forms question

  • Making FileDialogs as Child Windows
    T TyrionTheImp

    Hi, I was wondering if its possible to make a File Dialog (Open/Save as) become the child window of a parent form and be fully "contained and bounded" in it. I can`t find any straight-forward way to do this, like Controls.Add or anything since they inherit from Component class. I also tried calling the Win32 SetParent function but it has no effect. Any suggestions please ? Thanks in advance.

    Windows Forms question

  • Suggestions for Zorder Management
    T TyrionTheImp

    Hi All, I would like to create a module that manages ZOrders of windows in a system so that a particular group of windows (as identified by their Captions or Window Classes) are always together in zorder. This means no external apps (like notepad or Task Manager) should "interfere" with them. So far the approaches i`ve tried are : 1. Using Windows CBT Hooks to get Activation notifications for all windows in the system. Then based on which windows is being activated i do zorder management 2. Use the SetWinEvent Hook API , so whenever Foreground window changes i do my zorder management. But this is done "after" the foreground change has occured so to bypass it i use AttachThreadInput on the current foreground window, set my app window as the new Foreground window and then detach. Issue is ZOrder cant be maintained reliably and this sometimes causes my apps to hang. 3. Make all my app windows as Owned Windows of a single Owner window, but with this the internal ZOrder gets messed up if i show/hide my app windows. Is there any extra step i should take internally in my app windows, or issue some Messages form my Owner window before showing/activating any apps ? 4. A general question was : If I give SetWindowPos with the handle of a hidden window, or specify it as the hWndAfter parameter , what effect will this have on the ZOrder ? All my windows are TopLevel, Non-TopMost windows and they can create their own custom MessageBox and Dialogs (TopMost , Non-Topmost). So whatever mechanism i go with should be extensible to these message boxes too. Are there any other ways to this task ? Something better or faster ? I`ll be happy to provide more details if required. Any help and suggestions are most welcome. Thanks in advance.

    Windows Forms help question json lounge

  • Retaining Focus in owned Forms
    T TyrionTheImp

    hi , just tried the options u`ve suggested... unfortunately the problem still remains :( ShowDialog() works but then i must close that form before interacting with any other forms. Was the sample i uploaded useful ?

    Windows Forms help beta-testing question code-review
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups