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
C

CyberKewl

@CyberKewl
About
Posts
41
Topics
21
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • VBScript to C#
    C CyberKewl

    Thanks a lot! I'll put your name in the credits for this :)

    C# csharp com tutorial question

  • VBScript to C#
    C CyberKewl

    Thanks. It works (at least on WinXP) but i'm wondering how to get the other one to work : set SRP = getobject("winmgmts:\\.\root\default").InstancesOf ("systemrestore") for each Point in SRP msgbox point.creationtime & vbcrlf & point.description & vbcrlf & "Sequence Number= " & point.sequencenumber next

    C# csharp com tutorial question

  • VBScript to C#
    C CyberKewl

    I'm trying to write an app that handles system restore related stuff and would like to know how to convert the VBScript(s) in the following page into C# equivalent: http://support.microsoft.com/default.aspx?scid=KB;en-us;295299&

    C# csharp com tutorial question

  • Keyboard hooks - Problem
    C CyberKewl

    I have a problem with keyboard hooks - every time i press hold the CTRL+SHIFT key for quite some time, my application will crash with the error message : "An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll Additional information: Object reference not set to an instance of an object." I've searched high and low for a solution to this matter but to no avail. Here's the code that i am using, it is meant to disable keys like ALT+TAB, CTRL+ESC, etc: protected delegate int LowLevelKeyboardProcDelegate(int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam); [ DllImport( "user32.dll", EntryPoint="SetWindowsHookExA", CharSet=CharSet.Ansi )] protected static extern int SetWindowsHookEx(int idHook , LowLevelKeyboardProcDelegate lpfn, int hMod , int dwThreadId); [ DllImport( "user32.dll")] protected static extern int CallNextHookEx(int hHook,int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam); [ DllImport("user32.dll")] protected static extern int UnhookWindowsHookEx(long hhook); const int WH_KEYBOARD_LL = 13; public struct KBDLLHOOKSTRUCT { public int vkCode; int scanCode; public int flags; int time; int dwExtraInfo; } protected int intLLKey = 0; protected int LowLevelKeyboardProc(int nCode,int wParam,ref KBDLLHOOKSTRUCT lParam) { bool blnEat = false; switch (wParam) { case 256: case 257: case 260: case 261: //Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key if (((lParam.vkCode == 9) && (lParam.flags == 32)) || ((lParam.vkCode == 27) && (lParam.flags == 32)) || ((lParam.vkCode == 27) && (lParam.flags == 0)) || ((lParam.vkCode == 91) && (lParam.flags == 1)) || ((lParam.vkCode == 92) && (lParam.flags == 1)) || ((true) && (lParam.flags == 32))) { blnEat = true; } break; } if (blnEat) return 1; else { return CallNextHookEx(0, nCode, wParam, ref lParam); } } public void KeyboardHook() { intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, new LowLevelKeyboardProcDelegate(LowLevelKeyboardProc), System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]).ToInt32(),0); }

    C# help

  • Getting the height of a main menu
    C CyberKewl

    Thanks. That did the trick.

    C#

  • Getting the height of a main menu
    C CyberKewl

    Is there any way of obtaining the height of a main menu (menubar) or is it always the same size regardless of the screen resolution (i think its 20 pixels). The reason why i need to know the height is that i'm trying to make a form with a picturebox inside a panel and resize the form so that it can view the whole image (assuming that my screen res is larger than the image). So i need to do some calculations and stuff..

    C#

  • Database, ODP.NET, ADODC
    C CyberKewl

    I'm currently using ODP.NET (Oracle Data Provider) to connect to an oracle database. Is there a replacement control for ADODC (to go to the previous and next records) or do i have to create buttons myself for the navigational purposes?

    C# csharp database oracle question

  • Getting the active window handle
    C CyberKewl

    Yeah more or less. Here's the exact code : hWnd = FindWindow(null, "Form1"); RECT rc = new RECT(); GetWindowRect(hWnd, ref rc); this.Text = "LEFT" + rc.left + " RIGHT " + rc.right + " TOP " + rc.top; Image myImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); Graphics gr1 = Graphics.FromImage(myImage); IntPtr dc1 = gr1.GetHdc(); IntPtr dc2 = GetDC(hWnd); BitBlt(dc1, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, dc2, 0, 0, 13369376); gr1.ReleaseHdc(dc1); ReleaseDC(GetDC(hWnd)), dc2); GC.Collect(); Graphics gr = Graphics.FromHwnd(pictureBox1.Handle); pictureBox1.Image = myImage;

    C# tutorial

  • Getting the active window handle
    C CyberKewl

    I would like to know how to get the handle of the currently active window. I've tried using Findwindow and it works, but i want the whole view of the active window (including the toolbar and menubar) as i would like to create a program to take a screenshot of the active window (something like ALT+PRINTSCREEN but using BitBlt to do the capturing).

    C# tutorial

  • BitBlt performance in C#
    C CyberKewl

    No, that doesn't make much difference. The code is now : Image myImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); Graphics gr1 = Graphics.FromImage(myImage); IntPtr dc1 = gr1.GetHdc(); IntPtr dc2 = GetDC(GetDesktopWindow()); BitBlt(dc1, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc2, 0, 0, 13369376); gr1.ReleaseHdc(dc1); ReleaseDC(GetDesktopWindow(), dc2); GC.Collect(); return myImage; I fail to mention earlier that i am utilising a savejpgwithcompression function and after some checking, it appears that it is the cause of the problem. It could be the compression part, but it is essential to make the file size smaller. Here's the code : private void SaveJPGWithCompressionSetting( Image image, string szFileName, long lCompression ) { EncoderParameters eps = new EncoderParameters(1); eps.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, lCompression ); ImageCodecInfo ici = GetEncoderInfo("image/jpeg"); image.Save( szFileName, ici, eps ); } private ImageCodecInfo GetEncoderInfo(string mimeType) { ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); foreach (ImageCodecInfo codec in codecs) { if (codec.MimeType == mimeType){return codec;} } return null; }

    C# graphics csharp performance question

  • BitBlt performance in C#
    C CyberKewl

    I'm using the following code to capture a screenshot : Image myImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); Graphics gr1 = Graphics.FromImage(myImage); IntPtr dc1 = gr1.GetHdc(); IntPtr dc2 = GetDC(GetDesktopWindow()); BitBlt(dc1, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc2, 0, 0, 13369376); gr1.ReleaseHdc(dc1); GC.Collect(); return myImage; I'm trying to capture a screenshot of the entire desktop and transferring it to a remote PC (to create a program like PcAnywhere). The thing is, i set my screenshot timer to something like 450 ms and on my machine (Athlon XP 2000+), it uses up around 30% of the CPU power. However, if i test it on my old P3-700 Mhz machine, the CPU utilisation is very high, ranging between 75-90%. Is there any way to reduce the CPU utilisation (maybe like reducing the color depth of the image? but how)?

    C# graphics csharp performance question

  • Cursor detection problem
    C CyberKewl

    Cursor.Current only detects the cursor within the form. I need to detect the cursor system-wide (i.e: both inside and outside the form).

    C# json help question

  • Cursor detection problem
    C CyberKewl

    I'm trying to detect which cursor is currently shown on the screen, whether it is a wait cursor, arrow cursor, etc. Right now, the detection works perfectly EXCEPT that there are 3 cursors that i can't seem to detect sometimes - the hand cursor, horizontal and vertical splitter cursors. The code i'm using is (with the GetCursorInfo API): Info.Size = Marshal.SizeOf(Info.GetType()); GetCursorInfo(out Info); if (Info.Cursor == Cursors.WaitCursor.Handle) CurrentCursor = "Wait"; else if (Info.Cursor == Cursors.Default.Handle) CurrentCursor = "Default"; else if (Info.Cursor == Cursors.AppStarting.Handle) CurrentCursor = "Loading"; else if (Info.Cursor == Cursors.Hand.Handle) CurrentCursor = "Hand"; .... After i did some tests, i noticed that when i convert the values to string, the two values of Info.Cursor and Cursors.Hand.Handle (along with the HSplit and VSplit values as well) do not tally and they tend to change over and over again almost every time i run my application again. The tests were done by displaying the values of Info.Cursor and Cursors.Hand.Handle using codes like these: MessageBox.Show(Info.Cursor.ToString()); MessageBox.Show(Cursors.Hand.Handle.ToString()); I did the tests mostly on Applications that have a weblink and also on web browsers. When using a web browser, the detection seems fine (for the hand cursor at least) but when i run an app that has a weblink somewhere and the hand cursor shows up, the values of Info.Cursor and Cursors.Hand.Handle are totally different. Is there a way around this?

    C# json help question

  • GetCursorInfo in C#?
    C CyberKewl

    Thanks a lot. That did the trick.

    C# csharp com json tutorial question

  • GetCursorInfo in C#?
    C CyberKewl

    No, i just need to know the name of the cursor whether it is a normal cursor showing or wait cursor showing - system-wide (not just within the current form). From my understanding, if you use Cursor.Current, you can only get the name of the cursor that is showing within the form. If the cursor moves outside of the form, the name of the cursor will not be changed.

    C# csharp com json tutorial question

  • GetCursorInfo in C#?
    C CyberKewl

    I'm aware of that. The thing is, i don't understand how to use GetCursorInfo. I just need some help in getting the cursor image which is vital for my program, that's all. Anyway, i'll try reading again.

    C# csharp com json tutorial question

  • GetCursorInfo in C#?
    C CyberKewl

    Thanks for the quick reply but i'd like to know how to use it too. I'd like to know how to get the cursor image (or icon) using GetCursorInfo.

    C# csharp com json tutorial question

  • GetCursorInfo in C#?
    C CyberKewl

    Does anyone know how i can use the GetCursorInfo API in C#? I'd like to know the dllimport and an example code. Click here to view the GetCursorInfo API.

    C# csharp com json tutorial question

  • How to get system-wide cursor status in c#?
    C CyberKewl

    After some extensive digging, i found out that to get the cursor "image" or icon, we need to use GetCursorInfo() but i don't know how to write the codes (particularly the dllimport part) and get it working in C#. Does anyone have any ideas?

    C# csharp tutorial question

  • How to get system-wide cursor status in c#?
    C CyberKewl

    Is it possible to obtain a system-wide cursor status? I've tried using Cursor.current.tostring() but it only returns the status of the cursor within the application running. This means that if the cursor status is updated OUTSIDE of the application, the status is not updated at all.

    C# csharp tutorial question
  • Login

  • Don't have an account? Register

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