Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#15

Re: keine gültige 16Bit Ressource

  Alt 26. Sep 2008, 19:59
Die resource wird nun erkannt aber nicht aufgerufen..
Ich mache folgendes kann aber nicht sagen ob das in Delphi machbar ist.
Unter Basic hab ich da kein problem.

Nachdem mein Window (Class) erstellt wurde initialisiere ich den Dialog über die API

Delphi-Quellcode:
// Lade die DialogBox von Resource
g_hInst := hInstance;
  DialogBox(g_hInst, MAKEINTRESOURCE(100), HWND_DESKTOP, @WndProc);
Jetzt sollte eigentlich in der WndProc WM_INITDIALOG: aufgerufen
und der Dialog angezeigt werden.

Hier meine WinProc
Delphi-Quellcode:
// Main Windowproc
function WndProc(WinHandle: HWND; Msg: UINT; wParam : Integer; lParam: Integer) : Integer; stdcall;

begin

  case Msg of

     WM_NCHITTEST:
    begin
       Result := HTCAPTION;
     Exit;
    end;

    WM_INITDIALOG:
      begin
        // Wähle das erste Option Control
        SendDlgItemMessage(WinHandle, 101, BM_SETCHECK, BST_CHECKED, 0);

        // Setze das Menu Handle
        hMenu := GetSubMenu(LoadMenu(g_hInst, 'POPUPMENU'), 0);

        // Addiere das Tray Icon
        ti.cbSize := SIZEOF(TNotifyIconData);
        ti.Wnd := WinHandle;
        ti.uID := g_hInst;
        ti.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
        ti.uCallbackMessage := WM_TRAYICON;
        ti.hIcon := LoadIcon(g_hInst, 'FACE1');
        ti.szTip := 'Water Gadgets';
        Shell_NotifyIcon(NIM_ADD, @ti);
        DestroyIcon(ti.hIcon);

        Result := 1;
        exit;
      end;

    WM_TRAYICON:
      case lParam of
        // Linker Button gedrückt
        WM_LBUTTONDOWN:
          if IsWindowVisible(WinHandle) = False then
            ShowWindow( WinHandle, SW_SHOW);

        // Rechter Button gedrückt
        WM_RBUTTONDOWN:
          begin
            if IsWindowVisible(WinHandle) = False then
              SetForegroundWindow(WinHandle);
              GetCursorPos(TrayMenuP);
              TrackPopupMenu(hMenu, 0, TrayMenuP.x,
                             TrayMenuP.y, 0, WinHandle, nil);
              Postmessage(WinHandle, WM_NULL, 0, 0);
          end;
      end;

    WM_COMMAND:
      begin
        case LoWord(WParam) of
          101, 105:
            begin
              // Ändere das TrayIcon
              ti.hIcon := LoadIcon(g_hInst, PAnsiChar('FACE' + IntToStr(LOWORD(wParam) - 100)));
              Shell_NotifyIcon(NIM_MODIFY, @ti);
              DestroyIcon(ti.hIcon);
            end;
          IDOK:
             // AboutBox aus der Resource Anzeigen - siehe Tray.rc
            DialogBox(g_hInst, MAKEINTRESOURCE(101), HWND_DESKTOP, @AboutProc);
          IDCANCEL:
            begin
            if MessageBox(WinHandle,
               'Möchten Sie das Programm wirklich beenden?',
               'Water Gadget',
                MB_ICONEXCLAMATION or MB_OKCANCEL) = IDOK then
                EndDialog(WinHandle, 0);
                Result := 1;
                Exit;
            end;
        end;
      end;

    WM_SYSCOMMAND:
      case wParam and $FFF0 of
        SC_MINIMIZE:
          begin
            ShowWindow(WinHandle, SW_HIDE);
            Result := 1;
            Exit;
          end;
        SC_CLOSE:
          begin
            ShowWindow(WinHandle, SW_HIDE);
            Result := 1;
            Exit;
          end;
      end;

    WM_KEYDOWN:
       if wParam = VK_ESCAPE then
          DestroyWindow(WinHandle);

    WM_DESTROY:
      begin
        PostQuitMessage(0);
        Shell_NotifyIcon(NIM_DELETE, @ti);
      end;
   end;
   result := DefWindowProc(WinHandle, Msg, wParam, lParam);
end;
EDIT:
Habs nochmal geändert waren ein paar kleine Fehler.

So könnt ihr sehen was ich vorhabe
gruss Emil
  Mit Zitat antworten Zitat