|
Hi,
I wrote a little C# program that should be able to catch messages to a window from a 4GL application and change the default behaviour.
I struggle with the repaint of an icon. It gets painted on the frame by my dll, and repainted if I move another window with the mouse over it. But if I overlay the window with another one and click on 'minimize' the icon does not get repainted. If I look with spy++ I see WM_ERASEBKGND being fired, my C# PaintExtras method is executed. Any idea how to solve this? I copied the C#-code below. It is a little different then the code I posted a couple of days before.
As a sidequestion: how do I dispose this dll from memory after I have done with it?
Regards,
Stefan.
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;
private const int GWL_WNDPROC = -4;
private IntPtr oldWndProc = IntPtr.Zero;
private Win32WndProc newWndProc = null;
private int widgetH;
#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, int widgetHandle)
{
this.AssignHandle((IntPtr)windowHandle);
widgetH = widgetHandle;
oldWndProc = GetWindowLong((IntPtr)windowHandle, GWL_WNDPROC);
newWndProc = new Win32WndProc(MyWndProc);
SetWindowLong((IntPtr)windowHandle, GWL_WNDPROC, newWndProc);
//Every window has a procedure associated with it that receives all the
//messages that are sent to it. To subclass a window means to replace the
//procedure associated with the window by another user-defined procedure.
//The main use of subclassing windows is to customize how a window
appears
//or behaves. The handle of the procedure associated with the window can
//be obtained by calling the GetWindowLong function:
}
private int MyWndProc(IntPtr hWnd, int Msg, int wParam, int lParam)
{
switch(Msg)
{
case WM_ERASEBKGND:
int calProc = CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
PaintExtras();
return calProc;
default:
return CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
}
}
public void PaintExtras()
{
int hdc = GetDC(widgetH);
if (hdc != 0)
{
int ret = ExtractIcon(this.Handle.ToInt32(),"C:\\somewhere\\x.ico",0);
int ret = DrawIcon (hdc, 1, 1, hIcon);
int ret = DestroyIcon (hIcon);
int ret = ReleaseDC(this.Handle.ToInt32(),hdc);
}
}
}
}
regards,
Stefan.
|
|
|
|
|
I've got a little problem... I wrote backup wizard that does the backup and if you selected the send via email option, it sends the files. Now on win98 it backup perfectly except for sending the email, it gives somekind of support error. Is the smtp only supported in 2000 and xp or is there any possible way that it can work in 98?
|
|
|
|
|
You might want to tell us what the EXACT error message is. Win98, out of the box, does have any support for a SMTP client. IIRC, the message objects only work on 2000 and above.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok I'll get back to you on that.
|
|
|
|
|
Hello!
I am making a simple php-editor and right now I'm working on the intelliprompt memberlist. It is supposed to show with all the php functions. I then needed to store all the phpfunctions and information about them somehow. I choosed to use an xml file. The xml file looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<FunctionList Language="PHP">
<Functions>
<Function Name="abs" ReturnType="number">
<Parameters>
<Parameter Name="number" Type="mixed" />
</Parameters>
<Description>
<![CDATA[
Returns the absolute value of number. If the argument number is of type float, the return type is also float, otherwise it is integer (as float usually has a bigger value range than integer).
]]>
</Description>
</Function>
<Function Name="acos" ReturnType="float">
<Parameters>
<Parameter Name="arg" Type="float" />
</Parameters>
<Description>
<![CDATA[
Returns the arc cosine of arg in radians. acos() is the complementary function of cos(), which means that a==cos(acos(a)) for every value of a that is within acos()' range.
]]>
</Description>
</Function>
</Functions>
</FunctionList>
And I was wondering whats the best way of looping though every functions element and taking out name, returntype, all the parameters (name, type) and the description and adding it into objects?
I would appreciate a little code examples (they don't have to be complete or working) so I get what you mean.
Thanks in advance!
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
Martin Lundberg wrote:
And I was wondering whats the best way of looping though every functions element and taking out name, returntype, all the parameters (name, type) and the description and adding it into objects?
Search MSDN about XmlSerializer. It can do all that you described and MSDN has plenty of samples of its use.
Yes, even I am blogging now!
|
|
|
|
|
Thanks!
You don't happend to know if you can view a XML Schema Defenition as text instead of a digram in Visual Stusio 2005?
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
Hello
I have a database of a library system. I create a report that will display all the overdue books. I have looked at the wizard for creating the reports. But nothing that allows me to do this type of query.
SELECT BookRef, Title, DateDue FROM Book WHERE DateDue < '" + txtCurrentDate.Text + "' ";
But l am not sure how to create a report that will execute this query.
Thanks in advance,
Steve
|
|
|
|
|
Has anyone figured out how to use NDoc to pull the XML comments out of a web site in 2005? Since they changed the way web projects work (they don't have a project file and you can't set the XML documentation file option), I can't use NDoc to generate documentation. Any ideas?
Jeff Martin
My Blog
|
|
|
|
|
I've been looking at 3 books as im currentlty intrested in learning how to make crossplatform .NET aplications that run on Linux:
Cross-Platform .NET Development: Using Mono, Portable.NET, and Microsoft .NET
http://www.amazon.co.uk/exec/obidos/ASIN/1590593308/ref=cm_mp_wli_/202-5494928-0984624
Mono: A Developer's Notebook
http://www.amazon.co.uk/exec/obidos/ASIN/0596007922/ref=cm_mp_wli_/202-5494928-0984624
Mono Kick Start
http://www.amazon.co.uk/exec/obidos/ASIN/0672325799/ref=cm_mp_wli_/202-5494928-0984624
Has any one read or heardanything about these books and able to recormend anyof them or any other books on the subject of crossplatform .NET applicatios?
Thanks.
|
|
|
|
|
Hi,
Here we are facing problem which i am describing as below.
We are having scanned image but this image is skewed at some angle (we don know the angle) and may be shifted / translated sometimes.Our goal is to find out the Rectangle of predefined height and width by which we can get the 4 end points of Ractangle.Here color of that Rectangle is Pure Black and backggroud color is white.Here we are having only one Regular Rectangle in an image and our image is black and white.
so let's know the methods of finding End point co-ordinate of that Rectangle.
Thanks in Advance.
regards.,
montu3377
|
|
|
|
|
Hi,
I need to add a MenuItem into the Operating System ContextMenu that works just for a specific client application. For example when i right click on a field of my client i need it to show me the standard contextmenu (with cut, copy, past ect.) along with a personal menuitem in a specific position...
Any ideas?
Thanks in advance, and keep in mind i'm a real newbye in programming
|
|
|
|
|
You can add contextMenu...in registry.
In fact you can add menu, button in IE, etc.
MSDN related this...
|
|
|
|
|
I told you I'm a newbye in programming... in any case I'm going to check on MSDN again... Thanks for the tip
|
|
|
|
|
|
Thanks again, i'm gonna check asap... but i don't think i'm going to finish so soon
Later...;)
|
|
|
|
|
This requires COM interop and shell integration. Search codeproject for "C# does shell" and you should get some helpful hits.
Any remotely useful information on my blog will be removed immediately. There are 10 kinds of people in the world. Those who have heard of the ubiquitous, overused, worn-out-like-an-old-shoe binary "joke" and those who haven't.
Judah Himango
|
|
|
|
|
I am a junior software engineer. I for building my applications, So times i need quick help. So it is requested to all those guys who have experience in asp.net and C# to kindly add me in their msn address list. or send me their ids , i will add them to my msn id.....
My address is
giki_guy@hotmail.com
I will be very much thankful to all of you....
|
|
|
|
|
Hi Allah Kaa Bandaa,
Yaar you can post your problem on code project web site. So than you can get more help more people visit your problem and you got more help..
Anyways what's you problem maybe i can help you. i am currently working in c#.net asp.net & winforms.
Take care and Allah Hafiz....
Muhammad Waqas Butt
|
|
|
|
|
thankx for ur well wishes....
But dear friend, add me in ur messenger list, so that i can get ur response quickly.... my address is
giki_guy@hotmail.com
I am thankful to you and all other guys who will add me in order to help me..
|
|
|
|
|
|
Allah Kaa Bandaa wrote:
So it is requested to all those guys who have experience in asp.net and C# to kindly add me in their msn address list.
Well, I'd rather not. And I'll tell you why.
If I did this to everyone who could possibly want assistance I'd never get anything done. I'd be spending all my day giving out free advice.
You should post your questions in the relevant forums like this one and someone who has the time to answer your question will help you. You might ask a question that has many possible answers and by posting in a forum you will get multiple replies with the different possibities. You can then choose the answer that fits best with your situation. You benefit by posting in forums by getting a broader range of answers than a one-on-one session in MSN or Yahoo.
Finally, and this is the best reason, forums are searchable. That means that if someone has a similar problem they can search for the answer. Searching for the answer is a most valuable skill.
Do you want to know more?
WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums
|
|
|
|
|
I don't think so! None us here who answer questions regularly are "on call" to answer peoples questions right when they need them answered. We do this in our spare time and we don't get paid to do it. The last thing I need is another "pager" sitting on my hip.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
There are hundreds of people (or even more) logging in to CP forums everyday.
From my experience, these people will always try to help whenever they're able to and share their knowledge. Heck, some of them even go the extra step on finding out stuff they don't know about.
I'm sure it'll be quick enough for you to post a question and browse Google and MSDN for more information while waiting for someone to answer your post.
PS: Make your questions short, precise, clear, AND polite so others will be more inclined to answer them.
Edbert P.
Sydney, Australia.
|
|
|
|
|
hi all
Reasons given by all of u are correct but i have some more reasons.
So days ago, i have a problem in inserting data into the table of SQL Server through C#. I tried it many times, posted it on another forum ( not cp ). after many hours , i got the response, and the problem was that i was missing only a comma in the string. This was a very short problem, had it been corrected quickly, it may have taken me only five minutes to complete my task, which otherwise took many hours. Many times such things happen. For this type of things i am asking for some kind persons to add me.
For longer problem , i agree that they must be posted on the CP so that other people can also be benefited by them. And there must be many possible solutions that come as a output for that big problem. But for small problems like the one mentioned above, i donot think that there are many solutions for that, and if it takes hours to solve problem like mentioned in above para, then i think its better to leave the software engg and start so other work.
As for as the point that no one can help other instananiously, because no one is free..... i will only say that if a person can come to cp and spend his hours to answer the queries, then that person can also spend seconds to answer questions like described in first para, ask from them on the messenger.
Now i think that, if there are some kind persons available there in this forum, then they will surely add me to their messenger list in order to solve the short problem of their younger brother....
Looking for very much health response...
|
|
|
|
|