Witam,
Pisałem sobie serwer do mojej gry i chciałem przerobić go na WinAPI z użyciem RAD C++ ( jak zwykle miałem w zwyczaju to robić ). Wpadłem na pomysł, aby dodać Baloon Tipa do paska Tray'a w systemie. Tak więc zrobiłem. Jednak zaimplementowanie tych tipsów wiązało się z koniecznością deklaracji _WIN32_IE na co najmniej 0x0500.
Najdziwniejsze teraz jest to, że gdy do formy podczepiam funkcję okna zostaje wyrzucany wyjątek:
---------------------------
RAD C++ runtime check
---------------------------
Assertion failed!
Program: C:\Dev-Cpp\Ether Fields Server\Ether Fields Server.exe
FILE: C:/Dev-Cpp/include/radc++.h
LINE: 342
Expression: m_cObject != NULL
Compiled on : Aug 5 2009 at 10:06:10
Please consult RAD C++ help manual available at www.radcpp.com
---------------------------
Przerwij Ponów próbę Ignoruj
---------------------------
Jest to o tyle dziwne, że RAD to native WinAPI przedefiniowany jedynie. Chmurki działają prawidłowo, gdyż testowałem je przed przypisaniem do formy funkcji.
Zamieszczam tutaj kawałek serwera, gdzie wykorzystywany jest RAD C++
#define NTDDI_VERSION NTDDI_WIN2K
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
#define _WIN32_IE 0x0500
#include <windows.h>
#include <radc++.h>
#include "ControlKey.h"
int Border;
Form form1("Ether Fields Server" , 0 , 0 , 500 , 350 , RCP_POPUP , true , false , false , false , true , HWND_DESKTOP , false , WS_EX_APPWINDOW );
RichTextBox Console( "Consola" , 0x0312 , 5 , 5 , 500 , 350 , form1 );
TextBox Command( "Command" , 0x0313 , 5 , 0 , 500 , 22 , form1 );
HICON Ikona,Login;
#define con( a ) \
pthread_mutex_lock( &pCommand ); \
Console.text = Console.text + ( a ) + "\n"; \
SendMessage(Console.hwnd , WM_VSCROLL, SB_BOTTOM, 0); \
pthread_mutex_unlock( &pCommand );
BOOL ShowBalloonTip(LPCTSTR szMsg, LPCTSTR szTitle = "Ether Fields Server", UINT uTimeout = 5000, DWORD dwInfoFlags = 0x00000014 )
{
NOTIFYICONDATA NotifyIconData;
memset(&NotifyIconData, 0, sizeof(NOTIFYICONDATA));
NotifyIconData.cbSize = sizeof(NOTIFYICONDATA);
NotifyIconData.hWnd = form1.hwnd;
NotifyIconData.hIcon = Login;
NotifyIconData.uFlags = NIF_ICON | NIF_TIP | NIF_INFO;
NotifyIconData.uTimeout = uTimeout;
NotifyIconData.dwInfoFlags = NIIF_INFO;
strcpy(NotifyIconData.szInfoTitle, szTitle);
strcpy(NotifyIconData.szInfo, szMsg);
strcpy(NotifyIconData.szTip, "Ether Fields Server" );
Shell_NotifyIcon(NIM_ADD, (NOTIFYICONDATA *)&NotifyIconData);
}
#include "Serwer.h"
//create procedure for form to receive events
FormProcedure Proc(FormProcArgs) {
ON_CLOSE() { //close applciation when form is closed
form1.minimize();
}
ON_MESSAGE( WM_QUIT ) {
form1.removeTrayIcon(); //remove the icon we set when quitting application
Application.close();
}
ON_MINIMIZE() {
form1.resetTrayIcon( Ikona ,"Show console");
Command.enabled = false;
Console.enabled = false;
ShowWindow( form1.hwnd , false );
form1.removeExStyle( WS_EX_APPWINDOW );
}
ON_INIT() {
Command.refresh();
Console.refresh();
}
ON_RESTORE() {
form1.resetTrayIcon( Ikona ,"Hide console");
ShowWindow( form1.hwnd , true );
form1.addExStyle( WS_EX_APPWINDOW );
SetForegroundWindow( form1.hwnd );
Command.refresh();
Console.refresh();
}
ON_SIZE() {
Console.resize( form1.cwidth-10 , form1.cheight-37 );
SendMessage(Console.hwnd , WM_VSCROLL, SB_BOTTOM, 0);
Command.resize( form1.cwidth-10 , 22 );
Command.moveTo( 5 , form1.cheight-27 );
}
ON_KEY_PRESSED( 0 , true , 0x0D, false, NULL , true ){
if( ! ( (string)( (String)Command.text ) ).empty() ){
con( "Command -> " + Command.text );
string result = CommandLine( (string)( (String)Command.text ) );
con( result );
Command.text = "";
Command.focus();
}
}
ON_TRAYICON_CLICK( form1 ) { //check if the tray icon has been clicked
if( !form1.isMinimized() )
form1.minimize();
else{
form1.restore();
Console.enabled = true;
Console.looseFocus();
Console.setSelection(0,-1);
SendMessage(Console.hwnd , WM_VSCROLL, SB_BOTTOM, 0);
Command.enabled = true;
Command.focus();
}
}
return 0;
}
int getTaskBarHeight()
{
RECT rect;
HWND taskBar = FindWindow("Shell_traywnd", NULL);
if(taskBar && GetWindowRect(taskBar, &rect)) {
return rect.bottom - rect.top;
}
return 0;
}
rad_main()
Ikona = LoadIcon(hInst,"IconSmall");
Login = LoadIcon(hInst,"Login");
form1.setIcon( Ikona );
form1.setExStyle( 0 );
Command.focus();
SendMessage( Console.hwnd , EM_SETREADONLY , 1 , 0 );
// O_o' OMG OCB ????
/// !!!! TUTAJ WYKRZACZA !!!!
form1.procedure = Proc;
/// !!!! TUTAJ WYKRZACZA !!!!
form1.setTrayIcon( Ikona ,"Show console");
ShowWindow( form1.hwnd , true );
form1.addExStyle( WS_EX_APPWINDOW );
SetForegroundWindow( form1.hwnd );
form1.moveTo( GetSystemMetrics(SM_CXSCREEN) - form1.width , GetSystemMetrics(SM_CYSCREEN) - form1.height - getTaskBarHeight() );
Console.resize( form1.cwidth-10 , form1.cheight-37 );
Command.resize( form1.cwidth-10 , 22 );
Command.moveTo( 5 , form1.cheight-27 );
ShowBalloonTip( "Siemanko" );
Init();
while( GetMessage(&msg,NULL,0,0) ) {
if( ! IsDialogMessage(GetParent(msg.hwnd),&msg) ) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
ExitProcess( 0x16317 );
}
Z góry dziękuję za pomoc