473,324 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

hWnd error

32
I was told that this piece coding to find the es_password state in c# would work but an error message saying hWnd does not exist in the current context
Expand|Select|Wrap|Line Numbers
  1.   internal static class UnsafeNativeMethods 
  2.         {
  3.             public const int GWL_STYLE = -16;
  4.             public const int ES_PASSWORD = 0x20;
  5.             [DllImport("user32.dll")]
  6.             public static extern int GetClassName(HandleRef hWnd, System.Text.StringBuilder lpClassName, int nMaxCount);
  7.             [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
  8.             public static extern IntPtr GetWindowLong32(System.Runtime.InteropServices.HandleRef hWnd, int nIndex);
  9.  
  10.        }
  11.  
  12.  
  13.         private void tmrpass_Tick(object sender, EventArgs e)
  14.         {
  15.  
  16.             //start timer and espassword code
  17.  
  18.             // root the handle so it doesn't get disposed until were done with it
  19.  
  20.             Object root = new Object();
  21.  
  22.             System.Runtime.InteropServices.HandleRef handleRef = new System.Runtime.InteropServices.HandleRef(root, hWnd);
  23.             System.Text.StringBuilder sb = new System.Text.StringBuilder(1024);
  24.             // get the class name of the window
  25.             UnsafeNativeMethods.GetClassName(new System.Runtime.InteropServices.HandleRef(root, hWnd), sb, sb.Capacity);
  26.             // is it an edit box?
  27.             if (sb.ToString() == "Edit" || sb.ToString().StartsWith("WindowsForms10.EDIT.app"))
  28.             {
  29.                 // get the window style of the edit box
  30.                 int style = UnsafeNativeMethods.GetWindowLong32(new System.Runtime.InteropServices.HandleRef(root, hWnd), UnsafeNativeMethods.GWL_STYLE).ToInt32();
  31.                 // is it a password edit or not?
  32.                 if ((style & UnsafeNativeMethods.ES_PASSWORD) == UnsafeNativeMethods.ES_PASSWORD)
  33.                 {
  34.                     lblkd.Text = "edit is password text box";
  35.                 }
  36.                 else
  37.                 {
  38.                     lblkd.Text = "edit is not password text box";
  39.                 }
  40.             }
  41.  
  42.             //stop timer and es password code
  43.         }
  44.  
i had fixed up all these other errors but not this one.
if you have any slight of an idea please reply thanks
Sep 13 '08 #1
0 1300

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Joseph | last post by:
I read a piece of code, and the code looks like the following part. CWnd is a MFC class class CFrameGrabber : public CWnd { .... }; BOOL CFrameGrabber::Create(int x, int y, CWnd...
3
by: Juan Irigoyen | last post by:
I have the next code byte data = new byte; Marshal.Copy(this.Hwnd, data, 0, 4); this code compiled well, but when i execute the code receive a error. How can copy this.Hwnd (Handle of...
3
by: Andrew Moore | last post by:
Hi All, I have a managed C++ class that makes calls into the Win32 API. I specifically am trying to take a Handle from a .NET form and convert it to a HWND to pass to a Win32 functions. The...
17
by: Bonj | last post by:
Is PostQuitMessage(?) different to PostMessage(hWnd, WM_QUIT, ... ) ? I've got a window in a DLL (the same one experiencing the issue below, "return value of WM_QUIT") in which PostMessage(hWnd,...
4
by: quat | last post by:
Hello all, I have some unmanaged code that requires an HWND to a managed control (e.g., a picture box). I try: mRenderWnd->Handle; Of course, this returns an IntPtr. If I try to case, I...
15
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
How can I pass a C++ HWND to and from C# and Managed C++?
2
by: thesayan | last post by:
i am currently using vb 2005 and i am translating an old program from vb6 that a friend gave to me. my current error is this: lWindowHandle = Form1.hWnd 'hWnd is not a member of App.Form1' ...
1
by: thesayan | last post by:
hello, i am attempting to translate some code from vb6 into vb 2005 that draws sprites from graphics designs. i am having trouble on the form trying to draw to back buffer surface. 'vb6 code ...
11
by: =?ISO-8859-15?Q?Kolja_M=E4rtens?= | last post by:
Hello! I've been professionally working on java projects for several years, but have done extremely little C/C++ coding and just a few little things in VB.Net. Right now I'm trying to write a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.