HWND hText = NULL;
char gCharacterName[256];
HWND hSecondaryWindow = NULL;
HFONT hFontVerdana = NULL;
HCURSOR hCursor = NULL; //dont work
--------------------------------------------------------------------------------
void GetCharacterName(char* nombre) {
switch(*(DWORD*)(MAIN_SCREEN_STATE))
{
case 1:
wsprintf(nombre, "Carregando...");
break;
case 2:
wsprintf(nombre, "Selecionando Servidor...");
break;
case 3:
wsprintf(nombre, "Carregando Informações do Character...");
break;
case 4:
wsprintf(nombre, "Escolhendo Personagem...");
break;
case 5:
wsprintf(nombre, "Personagem: %s | Level: %d Resets: %d", (char*)(*(DWORD*)(MAIN_CHARACTER_STRUCT)+0x00), *(WORD*)(*(DWORD*)(MAIN_CHARACTER_STRUCT)+0x0E), ViewReset); // Edite as offsets de acordo com o main que irá utilizar
break;
default:
wsprintf(nombre, "Estado Desconhecido"); // Tratamento para estados não previstos
break;
}
}
-----------------------------------------------------------------------
// Procedimento da janela secundária
LRESULT CALLBACK SecondaryWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_CREATE:
// Configurar o controle de texto (STATIC)
hText = CreateWindow(_T("STATIC"), _T(""),
WS_VISIBLE | WS_CHILD | WS_BORDER | SS_CENTER,
10, 10, 320, 30, hwnd, NULL, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
// Criar a fonte Verdana
hFontVerdana = CreateFont(
15, // Altura da fonte
0, // Largura da fonte
0, // Ângulo de escapamento
0, // Ângulo de orientação
FW_NORMAL, // Peso da fonte
FALSE, // Itálico
FALSE, // Sublinhado
FALSE, // Tachado
DEFAULT_CHARSET, // Conjunto de caracteres
OUT_DEFAULT_PRECIS, // Precisão de saída
CLIP_DEFAULT_PRECIS, // Precisão de recorte
DEFAULT_QUALITY, // Qualidade de saída
DEFAULT_PITCH | FF_SWISS, // Pitch e família da fonte
_T("Verdana")); // Nome da fonte
// Aplicar a fonte Verdana ao controle de texto
SendMessage(hText, WM_SETFONT, (WPARAM)hFontVerdana, TRUE);
// Configurar um temporizador que dispara a cada 1000 milissegundos (1 segundo)
SetTimer(hwnd, 1, 1000, NULL);
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
// Desenhar o nome do personagem na janela
TextOut(hdc, 10, 10, gCharacterName, strlen(gCharacterName));
EndPaint(hwnd, &ps);
return 0;
}
case WM_TIMER:
// Atualizar o nome do personagem automaticamente
GetCharacterName(gCharacterName);
SetWindowText(hText, gCharacterName);
return 0;
case WM_CLOSE:
ShowWindow(hwnd, SW_HIDE); // Esconde a janela ao invés de destruí-la
return 0;
case WM_DESTROY:
if (hSecondaryWindow) {
DestroyWindow(hSecondaryWindow);
}
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
// Função para criar a janela secundária
void CreateSecondaryWindow(HINSTANCE hInstance) {
WNDCLASS wndClass = { 0 };
wndClass.lpfnWndProc = SecondaryWindowProc;
wndClass.hInstance = hInstance;
wndClass.lpszClassName = _T("SecondaryWindowClass");
// Carregar um cursor personalizado
hCursor = LoadCursor(NULL, IDC_HAND); // Substitua IDC_HAND pelo cursor desejado ou use LoadCursorFromFile para um arquivo de cursor personalizado
wndClass.hCursor = hCursor;
RegisterClass(&wndClass);
// Obter a resolução da tela
RECT desktop;
GetWindowRect(GetDesktopWindow(), &desktop);
// Definir a posição no canto inferior direito
int width = 355;
int height = 500;
int x = desktop.right - width;
int y = desktop.bottom - height;
hSecondaryWindow = CreateWindow(_T("SecondaryWindowClass"), _T("MuHorizon"),
WS_OVERLAPPEDWINDOW, x, y, width, height,
NULL, NULL, hInstance, NULL);
if (hSecondaryWindow) {
char nombre[20];
// Chamar a função para obter o nome do personagem
GetCharacterName(nombre);
if (hText) {
ShowWindow(hText, SW_SHOW);
UpdateWindow(hText);
// Inicialmente, obtenha o nome do personagem e defina o texto do controle STATIC
GetCharacterName(gCharacterName);
SetWindowText(hText, gCharacterName);
}
if (hSecondaryWindow) {
ShowWindow(hSecondaryWindow, SW_SHOW);
UpdateWindow(hSecondaryWindow);
// Inicialmente, obtenha o nome do personagem e defina o texto do controle STATIC
GetCharacterName(gCharacterName);
SetWindowText(hText, gCharacterName);
}
return;
}
}
DLL_PROCESS_ATTACH:
CreateSecondaryWindow((HINSTANCE)hModule);
case DLL_PROCESS_DETACH:
if (hSecondaryWindow) {
DestroyWindow(hSecondaryWindow);
}