Is there a possible way I can connect the WNDCLASSEX to the class in Gtk::WIndow??!
because I'm working on tray icon of gtkmm program for Windows. I already have a TrayIcon using this :

Shell_NotifyIcon(NIM_ADD, &g_notifyIconData);

But there is no function, it only display an icon it doesn't go in LRESULT Callback WndProc(.....).

NOTIFYICONDATA g_notifyIconData;
HWND g_hwnd;

Gtk::Window * mainWindow;
g_hwnd = reinterpret_cast<HWND>(GDK_WINDOW_HWND(mainWindow->get_window()->gobj())); //Gtk::window to HWND //everytime mainWindow run there's a tray icon, if the mainWindow quit it removes the tray icon

void MainWindow::InitNotifyIconData()
{

  memset( &g_notifyIconData, 0, sizeof( NOTIFYICONDATA ) ) ;

  g_notifyIconData.cbSize = sizeof(NOTIFYICONDATA);

  g_notifyIconData.hWnd = g_hwnd;
  g_notifyIconData.uID = ID_TRAY_APP_ICON;

  g_notifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP ;

  g_notifyIconData.uCallbackMessage = WM_TRAYICON; 

  g_notifyIconData.hIcon = (HICON)LoadImage( NULL, TEXT("tray.ico"), IMAGE_ICON, 0, 0, LR_LOADFROMFILE  ) ;

  stringcopy(g_notifyIconData.szTip, TEXT("TrayIcon"));

}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){     // I need to connect here

  if ( message==WM_TASKBARCREATED && !IsWindowVisible( g_hwnd ) )
  {
    Minimize();
    return 0;
  }

  switch (message)
  {
  case WM_CREATE:

    g_menu = CreatePopupMenu();

    AppendMenu(g_menu, MF_STRING, ID_TRAY_EXIT_CONTEXT_MENU_ITEM,  TEXT( "Exit" ) );

    break;

  case WM_SYSCOMMAND:
    switch( wParam & 0xfff0 )  
    {
    case SC_MINIMIZE:
    case SC_CLOSE:  
      Minimize() ;
      return 0 ;
      break;
    }
    break;

 
  case WM_TRAYICON:
    {

      switch(wParam)
      {
      case ID_TRAY_APP_ICON:
        break;
      }

      if (lParam == WM_LBUTTONUP)
      {
        Restore();
      }
      else if (lParam == WM_RBUTTONDOWN) 
      {
      
        POINT curPoint ;
        GetCursorPos( &curPoint ) ;

        SetForegroundWindow(hwnd); 

        UINT clicked = TrackPopupMenu(

          g_menu,
          TPM_RETURNCMD | TPM_NONOTIFY, 
          curPoint.x,
          curPoint.y,
          0,
          hwnd,
          NULL

        );

        if (clicked == ID_TRAY_EXIT_CONTEXT_MENU_ITEM)
        {
          PostQuitMessage( 0 ) ;
        }
      }
    }
    break;

  case WM_NCHITTEST:
  {
    UINT uHitTest = DefWindowProc(hwnd, WM_NCHITTEST, wParam, lParam);
    if(uHitTest == HTCLIENT)
      return HTCAPTION;
    else
      return uHitTest;
  }

  case WM_CLOSE:
    Minimize() ;
    return 0;
    break;

  case WM_DESTROY:
    PostQuitMessage (0);
    break;

  }

  return DefWindowProc( hwnd, message, wParam, lParam ) ;
}

WNDCLASSEX has lpfnWndProc = WndProc which is I think the one that connect to the LRESULT Callback WndProc(.....). But I can't declare my class in Gtk to WNDCLASSEX. Thanks in advance! :)

Instead of the WM_TRAYICON message, try WM_USER_SHELLICON.

Its still the same. :( Hmm.. How about this, is it possible way to register a class in gtkmm (Gtk::Window * MainWindow) in RegisterClassEx()? Because I need to have WndProc and I can't register the MainWindow in RegisterClassEx.

WNDCLASSEX wc;
wc.lpfnWndProc   = WndProc;
This article has been dead for over six months. Start a new discussion instead.