mfc - C#: Getting label injected into native app's statusbar pane to show up -
I am writing .Net COM DLL which runs in the original Windows application.
I'm trying to inject an extra pane in this app's statusbar, and there is no specific implementation to do this, so I try to sub-class myself to the app's statusbar I am doing
I'm using the Win32 API SetParent () one for the Msctls_statusbar32 example. Switch from the net form to the guardian of the label control. I used a label because it is the closest implementation of a native "static" class control that I could get without writing my control.
Either way I successfully managed to hook the Nevtevindo into both the status bar and the message of my label (although at the moment it only passes them all to the next WndProc), and I have the window of my label Matching styles and styleExs are assigned, and I can see my labels as a child with msctls_statusbar32 as my parents. Everything looks like as if it should work properly, but it is not. My control does not appear in the parent app's statusbar.
I do not understand why this is not showing almost all the things that I can think of correctly matching - the category for my label "WindowsForms10.STATIC.app.0.378734 A "and" stable ", but besides this it is on the right process and thread, matching window style (at least hex value ... detective ++ starts counting them separately), and for all purposes Is there a lot of mixing with the rest of the controls? Would that be to distinguish between what?
(I basically went to the path of CreateWindowEx and WNDPROC was establishing a callback but I could not make the app work ... it would be
thanks!
You can try to work with the current status bar control; what you can do To reset the text in an existing section or to add a new one; You may be given new width in existing sections of the statusbar You will need to know about how to work with the statusbase control here:
Please find an example of how to do this below. I was actually using the Win32 application #com object tried to do this with it and it seems to work fine for me
[ComVisible (right)] [Guid ("CC5B405F-F3CD-417E-AA00-4638A12A2E94") , ClassInterface (ClassInterfaceType.None)] Public Square TestInterface: Declaration of ITestInterface B // {bottom interface [DllImport ( "user32.dll", SetLastError = true)] public static exile IntPtr FindWindowEx (IntPtr parentHandle, IntPtr childAfter, String className, IntPtr windowTitle); [DllImport ("user32.dll", charset = CharSet.Auto)] Fixed Execution IntPtr SendMessage (IntPtr hWnd, UInt32 Message Int wParam, IntPtr lParam); Public const int SB_SETTEXT = 1035; Public const int SB_SETPARTS = 1028; Public const int SB_GETPARTS = 1030; Public Unsecured Zero Test () {IntPtr mainWindowHandle = Process GetCurrentProcess () MainWindowHandle; // Application IntPtr statusBarHandle = FindWindowEx gets the status bar control (mainWindowHandle, IntPtr.Zero "msctls_statusbar32", IntPtr.Zero) on the main window; If the (0) entry for the current part with the status bar (= StatusBarHandle! = IntPtr.Zero) {// set = IntPtr text = Marshal.StringToHGlobalAuto ("test lesson 0"); SendMessage (status barhandle, SB_ETTN, 0, text); Marshal.FreeHGlobal (text); // Create the width range of the new parts int nParts = SendMessage (Position BarHandle, SB_GETPARTS, 0, IntPtr.Zero). ToInt32 (); NParts ++; IntPtr memPtr = Marshall. Olloc hjelobal (size (int * * enparates); Int partWidth = 100; // width of the size of the set size (int i = 0; i & lt; nParts; i ++) {martial. WrititeInt32 (memPtr, i * sizeof (int), partWidth); PartWidth + = partWidth; } SendMessage (status barhandle, SB_SPARTS, NPRT, MMPT); Marshal.FreeHGlobal (memPtr); // Set text for new section IntPtr text0 = Marshal.StringToHGlobalAuto ("new section 1 text"); SendMessage (Status Barhandle, SBTETN, NPRT-1, Text0); Marshal.FreeHGlobal (text0); }}} [ComVisible (right) [Guid ("694C1820-04B6-4988-928F-FD858B95C880")] Public Interface ITestInterface {[DispId (1)] Zero Test (); }
Hope this helps,
Comments
Post a Comment