I commented out that portion of code because transparency works correctly, but if you look closely, it generates artifacts, especially when selecting text. However, I solved the problem just last night by looking at some templates on the forum in asm x86 and making the appropriate changes. Below, I show all the updated code. In attachment you will find image resource and the exe file. #include <windows.h>
#include <wingdi.h>
#include "ufmod.h"
#include "resource.h"
#include "song.h"
#pragma comment(lib, "Msimg32.lib")
#pragma comment(lib, "ufmod.lib")
#pragma comment(lib, "winmm.lib")
HINSTANCE hInst;
HBITMAP hBackground = NULL;
HBRUSH hBrushBackground = NULL;
HBRUSH hBrush;
COLORREF transparentColor = RGB(255, 0, 255); // Magenta color key
// Bitmap per il pulsante di chiusura
HBITMAP hBtnCloseNormal = NULL;
HBITMAP hBtnCloseHover = NULL;
// Procedura finestra del dialogo
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_INITDIALOG:
{
HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1));
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
SetWindowText(hwndDlg, L"Keygen Template by jNe");
// Imposta il testo predefinito
SetDlgItemText(hwndDlg, EDIT_username, L"Enter Username");
// play chip-tune <3
uFMOD_SetVolume(20);
uFMOD_PlaySong(songData, (void*)sizeof(songData), XM_MEMORY);
// BMP in background
hBackground = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(BMP_form));
hBrush = CreatePatternBrush(hBackground);
// set magenta color key
SetLayeredWindowAttributes(hwndDlg, transparentColor, 0, LWA_COLORKEY);
// --- FINE ---
// BMP close
hBtnCloseNormal = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(BMP_close));
hBtnCloseHover = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(BMP_close_hover));
if (hBtnCloseNormal) {
HWND hBtnClose = GetDlgItem(hwndDlg, BTN_CLOSE);
if (hBtnClose) {
BITMAP bm;
GetObject(hBtnCloseNormal, sizeof(bm), &bm);
SetWindowPos(hBtnClose, NULL, 0, 0, bm.bmWidth, bm.bmHeight,
SWP_NOMOVE | SWP_NOZORDER);
}
}
}
return TRUE;
case WM_ERASEBKGND:
return TRUE;
case WM_PAINT: {
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwndDlg, &ps);
if (hBackground) {
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcMem, hBackground);
BITMAP bm;
GetObject(hBackground, sizeof(bm), &bm);
BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem, hOldBmp);
DeleteDC(hdcMem);
}
EndPaint(hwndDlg, &ps);
}
return TRUE;
case WM_DRAWITEM: {
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
if (lpdis->CtlID == BTN_CLOSE) {
HDC hdcMem = CreateCompatibleDC(lpdis->hDC);
HBITMAP hBmpToUse;
if (lpdis->itemState & ODS_SELECTED) {
hBmpToUse = hBtnCloseHover; // HOVER
}
else {
hBmpToUse = hBtnCloseNormal; // NORMAL
}
if (hBmpToUse) {
HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcMem, hBmpToUse);
BitBlt(lpdis->hDC,
lpdis->rcItem.left, lpdis->rcItem.top,
lpdis->rcItem.right - lpdis->rcItem.left,
lpdis->rcItem.bottom - lpdis->rcItem.top,
hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem, hOldBmp);
}
DeleteDC(hdcMem);
}
}
return TRUE;
case WM_CTLCOLORDLG:
return (INT_PTR)hBrush;
case WM_CTLCOLOREDIT:
case WM_CTLCOLORSTATIC: {
HDC hdcEdit = (HDC)wParam;
int controlId = GetDlgCtrlID((HWND)lParam);
if (controlId == ABOUT) {
SetBkMode(hdcEdit, TRANSPARENT);
SetTextColor(hdcEdit, RGB(255, 255, 255));
SetBkColor(hdcEdit, 0x00000000);
SetBrushOrgEx(hdcEdit, -23, -88, NULL);
return (INT_PTR)hBrush;
}
if (controlId == EDIT_username) {
SetBkMode(hdcEdit, TRANSPARENT);
SetTextColor(hdcEdit, RGB(255, 255, 255));
SetBkColor(hdcEdit, 0x00000000);
SetBrushOrgEx(hdcEdit, -23, -88, NULL);
return (INT_PTR)hBrush;
}
if (controlId == EDIT_serial) {
SetBkMode(hdcEdit, TRANSPARENT);
SetTextColor(hdcEdit, RGB(255, 255, 255));
SetBkColor(hdcEdit, 0x00000000);
SetBrushOrgEx(hdcEdit, -23, -151, NULL);
return (INT_PTR)hBrush;
}
break;
}
case WM_LBUTTONDOWN:
SendMessage(hwndDlg, WM_NCLBUTTONDOWN, HTCAPTION, 0);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case EDIT_username: {
if (HIWORD(wParam) == EN_CHANGE) {
char username[256];
GetDlgItemTextA(hwndDlg, EDIT_username, username, 256);
SetDlgItemTextA(hwndDlg, EDIT_serial, "OMFG-THIS-IS-A-DEMO");
}
break;
}
case BTN_CLOSE:
SendMessage(hwndDlg, WM_CLOSE, 0, 0);
return TRUE;
}
break;
case WM_CLOSE:
uFMOD_StopSong();
if (hBrush) DeleteObject(hBrush);
if (hBackground) DeleteObject(hBackground);
if (hBtnCloseNormal) DeleteObject(hBtnCloseNormal);
if (hBtnCloseHover) DeleteObject(hBtnCloseHover);
EndDialog(hwndDlg, 0);
return FALSE;
}
return FALSE;
}
// Entry point
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
hInst = hInstance;
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
return 0;
}
keygen template - fix.zip