473,657 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hWnd error

32 New Member
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 1310

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

Similar topics

3
4329
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 *pParentWnd) { .......
3
3051
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 MessageWindow type IntPtr) to the first 4 bytes in data ?
3
11035
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 code works properly but I get the following compiler warning: warning C4312: 'reinterpret_cast' : conversion from 'int' to 'HWND' of greater size.
17
7085
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, WM_QUIT, ... ) works, but PostQuitMessage doesn't. I would assume this to be the case as PostQuitMessage can't possibly know the hWnd I'm wanting it to operate on. So why does the docs advise you to use that?
4
1716
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 get the error: Cannot convert a managed type to an unmanaged type
15
30099
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
How can I pass a C++ HWND to and from C# and Managed C++?
2
6127
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' this is using directX and from what i was told the hWnd should be defined by itself. if anyone knows a vb 2005 equivalent that'd be great. my main topic for this thread is this question. What exactly is hWnd and what does it do? mebbe if i learn...
1
1875
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 Dim lWindowHandle As Long Private Sub Form_Load() Static lStartTime As Long Static lCounter As Long Static lNewTime As Long
11
4620
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 Windows Service in VC++ .Net thats supposed to use a 3rd party SDK do receive Image data and send it out through a webservice.
0
8413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.