473,394 Members | 1,821 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,394 software developers and data experts.

RegisterClass fails the 2nd time it is called

I have on method call another method NotificationWndProc to create a notification window, which will receive messages. At the first time, things are running OK, but in the second time, it returns error:

RegisterClass returned 1410.

Please help me out!

In .cpp file:

Expand|Select|Wrap|Line Numbers
  1. {
  2. ...
  3.  
  4. long  (CALLBACK *WndProcPointer ) ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) = NotificationWndProc    ;
  5. wc.lpfnWndProc   = WndProcPointer;    
  6. wc.lpszClassName = NOTIFICATION_CLASS;
  7. wc.lpszMenuName  = NULL;
  8. wc.hInstance     = gVars.g_hInst;
  9. wc.hIcon         = NULL;
  10. wc.hCursor       = NULL;
  11. wc.hbrBackground = NULL;
  12. wc.cbWndExtra    = sizeof(PSNMP_MGR_SESSION);
  13. wc.cbClsExtra    = 0;
  14. wc.style         = 0;    // register class
  15. fOk = RegisterClass(&wc);
  16.  
  17. if (!fOk) 
  18. {
  19.      TRACE( "RegisterClass returned %d.\n", GetLastError() );
  20.      return (FALSE);
  21. }
  22.  
  23. ...
  24. }
  25.  
  26. LRESULT CALLBACK CACSSnmpUtil::NotificationWndProc(    
  27.                                                     HWND   hWnd,
  28.                                                     UINT   uMsg,
  29.                                                     WPARAM wParam,
  30.                                                     LPARAM lParam
  31.                                                    )
  32. {
  33.  
  34.     if (uMsg == WM_MSG_INCOMING) 
  35.     {
  36.  
  37.         PSNMP_MGR_SESSION pSession;
  38.         // retrieve session pointer from window
  39.    pSession = (PSNMP_MGR_SESSION)GetWindowLong(hWnd, 0);
  40.  
  41.         // validate session ptr
  42.         if ( pSession == NULL )
  43.             return (LRESULT)0;
  44.  
  45.         // process notification message
  46.         if ( ProcessNotification( pSession ) ) 
  47.         {
  48.             // post message to break out of message pump
  49.             PostMessage( pSession->hWnd, WM_MSG_DONE, (WPARAM)0, (LPARAM)0 );
  50.         }
  51.         return (LRESULT)0;
  52.  
  53.     } 
  54.     else 
  55.     {
  56.         // forward all other messages to windows
  57.         return DefWindowProc(hWnd, uMsg, wParam, lParam);
  58.  
  59.     }
  60.  
  61. } // end of NotificationWndProc
  62.  
In .h file:
static LRESULT CALLBACK NotificationWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
Jan 15 '07 #1
1 6827
Banfa
9,065 Expert Mod 8TB
You can look up the error code here where you will find it is ERROR_CLASS_ALREADY_EXISTS.

Once you have registered a class then there is no need to do so again unless you unregister it.

It is normal to only register classes once for an application not everytime it tries to create a window of that class.
Nov 6 '07 #2

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

Similar topics

3
by: Fabio Garufi | last post by:
Hi, all, I built the fftw-3.0.1-fma on a LynxOS 4.0 running on a board equipped with a PowerPC G4 7457. To compile it I had to slightly modify the configure script to use the -fvec instead of...
0
by: Ted Miller | last post by:
I have a managed class that registers a window class with the usual Win32 RegisterClass API. // Global function, not part of class LRESULT CALLBACK MyWindowProc( IN HWND hwnd, IN UINT Msg,...
29
by: Ken Allen | last post by:
I have a number of services developed in C# (.Net), and they have been working fine for the most part. Recently someone reported that ipon occassion (originally rarely, but more frequently on some...
0
by: Gianluca | last post by:
Anyone knows if the bug in NativeWindow.RegisterClass and the class names list being case sensitive is scheduled to be fixed or already fixed? In short, NativeWindow.RegisterClass keeps a list of...
12
by: keepyourstupidspam | last post by:
Hi, I am writing a windows service. The code runs fine when I start the service when my machine is running but it fails to start automatically when the machine reboots. The code bombs out when...
1
by: chriskent | last post by:
Hi, I have an unusual situation whereby we create a Window during initialisation. We have used this code for many years and have found one unusual case with a customer when the RegiterClass fails...
6
by: ranin02 | last post by:
Hi, I have a COM method that is called from VBA. This COM method in turn calls CoCreateInstance on a class that is a .NET class with a COM wrapper around it. This all works fine. However,...
4
by: =?Utf-8?B?QXJtaW4gR2FsbGlrZXI=?= | last post by:
Hi I wrote a test for a workflow. Unfortunately my assertions in the eventhandler which I set up during initialization, fail in every case... What's the problem?? public void...
1
by: ErikJL | last post by:
I have a simple webservice that performs a SELECT query against a database, and then an INSERT statement on the same database/table. The problem arises at the time when we create the second OleDB...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.