Thanks for your Answer but I still get the same Error Message (with your TRACKMOUSEEVENT structure) :/
TyronX
Posts
-
Error 998 on Windows API Call -
Error 998 on Windows API CallThe TrackMouseEvent function fails and returns zero. So I called (as msdn advised me) GetLastError() to get the error msg and it returns 998 which means: ERROR_NOACCESS Invalid access to memory location. Has anyone a clue what my OS is trying to tell me here? I guess the error is caused by the c++ struct which the function takes as parameter. ( TRACKMOUSEEVENT Struct on MSDN )
[DllImport("kernel32.dll", SetLastError=true)] static extern int GetLastError (); [DllImport("user32")] public static extern bool TrackMouseEvent(TRACKMOUSEEVENT lpEventTrack); [StructLayout( LayoutKind.Sequential,CharSet=CharSet.Ansi)] public struct TRACKMOUSEEVENT { public long cbSize; public long dwFlags; public long hwndTrack; public long dwHoverTime; } and in the C# App Constructor: TRACKMOUSEEVENT foo = new TRACKMOUSEEVENT(); foo.cbSize = Marshal.SizeOf(typeof(TRACKMOUSEEVENT)); foo.dwFlags = TME_NONCLIENT; foo.hwndTrack = (long)this.Handle; bool bar = TrackMouseEvent(foo); MessageBox.Show(""+GetLastError());
-
Evil 'Show Desktop' or drawing on the Desktop?>The Show Desktop Icon (or Winkey+D) always minimizes my form and i couldn't find any way to prevent that. I discoverd that when I click "Show Desktop" that I get the Mesage WM_ACTIVATEAPP which tells me that my app gets deactivated and a thread from the explorer.exe Process gets activated. So far so good, but how do I prevent now that my app gets minimized?
-
Evil 'Show Desktop' or drawing on the Desktop?I coded some kind of electronical Post-it notes and I want to stick them on the Windows Desktop, but how? The Show Desktop Icon (or Winkey+D) always minimizes my form and i couldn't find any way to prevent that. Another Idea would be to directly draw my stuff on the Desktop but I don't know how to register to the OnPaint event of the desktop to redraw my stuff. Thanks a lot in advance.
-
Crashing Codeok thanks.
-
Crashing CodeI used http://www.codeproject.com/cs/media/perpxalpha\_sharp.asp to create a non-rectangular window. Then I tried to add a Label Form, but that didn't work (didn't show up). Therefore I thought that this maybe wouldn't be possible when you have a this type of window and tried directly to draw strings in my loaded bitmap:
Graphics g = Graphics.FromImage(newBitmap); newBitmap.Dispose(); Font font = this.Font; Brush brush = new SolidBrush(Color.White); g.DrawString("Hallo wie geht es dir?",font,brush, 50,50); g.DrawImage(newBitmap,0,0); bitmap = newBitmap;
newBitmap contains the loaded png (with alpha mask) image. The assignment of bitmap seems to crash (System.ArgumentException) because I disposed newBitmap. But why? I however assigned newBitmap again with g.DrawImage... -
Caption BarI used the WM_NCLBUTTONDBLCLK Event
-
Caption BarOkay I found the answer for my first question.
-
Caption BarHow can i detect if a user has double-clicked the caption bar of a form (which normally causes the window to maximize)? And is there a way to add icons in the upper left corner (left from the quit, maximize and minimize boxes)?
-
Multiple InstancesAfter using Mutexes and also implementing FindFindow if hwnd is zero everything works fine, it's even way faster. Thanks a lot!
-
Multiple InstancesI'm sorry if my comments sound to offensive/overacting. I alway speak a little bit to rough, I'll try better next time :)
-
Multiple Instances>You mentioned that your previous attempt didn't work. Were you using a mutex? No, I didn't say that. But indeed I aint using one cause I don't now I which Namespace the Mutex Class is (and yet I was to lazy to serch for that).
-
Multiple InstancesWeird. My Program doesn't get a message when the window is hidden.
-
Multiple InstancesWhat the hell... now it takes 1-2 seconds longer to start up. And btw. your code crashes. It seems to be that some proccess have a read protected process.MainModule Class. If I wrap around a try-catch it works. Thx for the answer
-
Multiple InstancesI want to avoid, that the user can start multiple instances of my programm. I found an article on CodeProject which helped, but it's a little bit confusing now when the user tries to start the programm and in doesn't start. Therefore I want, that the second instance activates (setting the windowstate to normal, calling Show() and Activate() the first instance (when it's minized or minimized to tray) before it closes itself. How do I do that?
-
Poor PointsYes indeed, and everything is explained on MSDN. All my fault :( Actually I tried to convert a string into a point and also tried to sumarize two Points. Well, at least now I know how it works :)
-
simple chat........What you need is a RichTextBox. Read about it on MSDN
-
Poor PointsThe System.Drawing.Point Class has really a lot of missing Features. It has no TypeConverter and no support for operators like + and -. This is really weak. Is there any possibility to fix that issue? Sure... I could write an own Point class but that one won't be compatible with all the (drawing-)functions like DrawPoly and I don't want to write some ugly conversion code.
-
beginner: reflection helpI guess It's like the same as including methods from the user32.dll: [DllImport("user32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Winapi)] private static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, IntPtr lParam);
-
Extending Classes?Next Question: Can I add something to the Point Class/Structure (I need to add the TypeConverter)?