Click here to Skip to main content
15,892,768 members
Home / Discussions / C#
   

C#

 
GeneralRe: DoubleBuffer problem .. Pin
Dave Kreskowiak21-Dec-04 5:28
mveDave Kreskowiak21-Dec-04 5:28 
GeneralRe: DoubleBuffer problem .. Pin
Heath Stewart21-Dec-04 12:38
protectorHeath Stewart21-Dec-04 12:38 
GeneralRe: DoubleBuffer problem .. Pin
Dave Kreskowiak21-Dec-04 16:20
mveDave Kreskowiak21-Dec-04 16:20 
GeneralRe: DoubleBuffer problem .. Pin
Heath Stewart22-Dec-04 6:12
protectorHeath Stewart22-Dec-04 6:12 
GeneralRe: DoubleBuffer problem .. Pin
Dave Kreskowiak22-Dec-04 11:53
mveDave Kreskowiak22-Dec-04 11:53 
GeneralRe: DoubleBuffer problem .. Pin
Skynyrd21-Dec-04 10:44
Skynyrd21-Dec-04 10:44 
GeneralRe: DoubleBuffer problem .. Pin
Sharpoverride22-Dec-04 23:40
Sharpoverride22-Dec-04 23:40 
Generalcalling a function in a subclassed window Pin
stefan houtz21-Dec-04 1:28
stefan houtz21-Dec-04 1:28 
Hello,

I run the program below to handle winmessages from an application written in a 4GL. From within PaintExtras() I would like to call a function in the 4GL program to retrieve some properties (to be able to draw the icon on different positions f.e.). How can I do that? I can send the 4GL 's window-HWND to NotifyWindow in my C# program.


using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsApplication1
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class GenericWindow : NativeWindow
{
public const int WM_ERASEBKGND = 0x14;
public const int WM_DESTROY = 0x0002;
private const int GWL_WNDPROC = -4;
private const int WM_SYNCPAINT = 0x0088;
private const int WM_NCPAINT = 0x0085;
private const int WM_PAINT = 0x000F;
private IntPtr oldWndProc = IntPtr.Zero;
private Win32WndProc newWndProc = null;
private int hIcon;

#region Imported User32.DLL functions

[DllImport("user32.dll", CharSet=CharSet.Auto)]
static public extern int GetDC(int hWnd);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int ReleaseDC(int hWnd,int hDc);
[DllImport("User32.dll")]
private static extern int DestroyIcon(int hIcon);
[DllImport("user32.dll")]
public static extern int DrawIcon(int hdc, int x,int y, int hIcon);
[DllImport("user32.dll", EntryPoint="CallWindowProc")]
private static extern int CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
public static extern int ExtractIcon(int hInst, string lpszExeFileName, int nIconIndex);
[DllImport("user32.dll")]
private static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, Win32WndProc newProc);
[DllImport("user32.dll")]
private static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);

#endregion

// A delegate that matches Win32 WNDPROC:
private delegate int Win32WndProc(IntPtr hWnd, int Msg, int wParam, int lParam);

public GenericWindow()
{

}

public void NotifyWindow(int windowHandle)
{
this.AssignHandle((IntPtr)windowHandle);
oldWndProc = GetWindowLong((IntPtr)windowHandle,GWL_WNDPROC);
newWndProc = new Win32WndProc(MyWndProc);
SetWindowLong((IntPtr)windowHandle, GWL_WNDPROC,newWndProc);
PaintExtras();
}
private int MyWndProc(IntPtr hWnd, int Msg, int
wParam, int lParam)
{
int pHandle;
switch(Msg)
{
case WM_PAINT:
pHandle = CallWindowProc(oldWndProc, hWnd,Msg, wParam, lParam);
PaintExtras();
return pHandle;
case WM_DESTROY:
pHandle = CallWindowProc(oldWndProc, hWnd,Msg, wParam, lParam);


//MessageBox.Show("dest");
return pHandle;
default:
return CallWindowProc(oldWndProc, hWnd, Msg,
wParam, lParam);
}
}


public void PaintExtras()
{
int hdc = GetDC(this.Handle.ToInt32());
if (hdc != 0)
{
hIcon = ExtractIcon(this.Handle.ToInt32(),"C:\\progress10\\wrk\\experim\\down.ico",0);
int ret = DrawIcon (hdc, 1, 1, hIcon);
ret = DestroyIcon (hIcon);
ret = ReleaseDC(this.Handle.ToInt32(),hdc);
}
}
}
}


regards,

Stefan.
GeneralC# XPath Problems Pin
Chua Wen Ching20-Dec-04 23:00
Chua Wen Ching20-Dec-04 23:00 
GeneralRe: C# XPath Problems Pin
Heath Stewart21-Dec-04 12:36
protectorHeath Stewart21-Dec-04 12:36 
GeneralDisplaying IIS directories/sites in C# Application Pin
Adnan Siddiqi20-Dec-04 22:43
Adnan Siddiqi20-Dec-04 22:43 
GeneralRe: Displaying IIS directories/sites in C# Application Pin
Heath Stewart20-Dec-04 22:53
protectorHeath Stewart20-Dec-04 22:53 
GeneralRe: Displaying IIS directories/sites in C# Application Pin
Adnan Siddiqi21-Dec-04 0:34
Adnan Siddiqi21-Dec-04 0:34 
GeneralRe: Displaying IIS directories/sites in C# Application Pin
Heath Stewart21-Dec-04 7:54
protectorHeath Stewart21-Dec-04 7:54 
GeneralRe: Displaying IIS directories/sites in C# Application Pin
Adnan Siddiqi31-Dec-04 20:13
Adnan Siddiqi31-Dec-04 20:13 
GeneralRe: Displaying IIS directories/sites in C# Application Pin
Heath Stewart31-Dec-04 22:42
protectorHeath Stewart31-Dec-04 22:42 
GeneralRe: Displaying IIS directories/sites in C# Application Pin
Adnan Siddiqi2-Jan-05 19:50
Adnan Siddiqi2-Jan-05 19:50 
GeneralRe: Displaying IIS directories/sites in C# Application Pin
Heath Stewart2-Jan-05 21:14
protectorHeath Stewart2-Jan-05 21:14 
GeneralRe: Displaying IIS directories/sites in C# Application Pin
Adnan Siddiqi3-Jan-05 7:55
Adnan Siddiqi3-Jan-05 7:55 
GeneralRe: Displaying IIS directories/sites in C# Application Pin
Adnan Siddiqi5-Jan-05 8:05
Adnan Siddiqi5-Jan-05 8:05 
GeneralSQL statement with result list restriction Pin
ppp00120-Dec-04 22:25
ppp00120-Dec-04 22:25 
GeneralRe: SQL statement with result list restriction Pin
Colin Angus Mackay20-Dec-04 22:45
Colin Angus Mackay20-Dec-04 22:45 
GeneralGDI+ nonrectangular forms problem Pin
sstoyan20-Dec-04 22:18
sstoyan20-Dec-04 22:18 
GeneralRe: GDI+ nonrectangular forms problem Pin
Heath Stewart20-Dec-04 22:45
protectorHeath Stewart20-Dec-04 22:45 
GeneralRe: GDI+ nonrectangular forms problem Pin
sstoyan21-Dec-04 3:33
sstoyan21-Dec-04 3:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.