refactor: Win32 선언부를 win32.go로 분리
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
171
win32.go
Normal file
171
win32.go
Normal file
@@ -0,0 +1,171 @@
|
||||
package main
|
||||
|
||||
import "golang.org/x/sys/windows"
|
||||
|
||||
// ── Win32 메시지 상수 ────────────────────────────────────────
|
||||
|
||||
const (
|
||||
wmDestroy uint32 = 0x0002
|
||||
wmClose uint32 = 0x0010
|
||||
wmSetFont uint32 = 0x0030
|
||||
wmSetText uint32 = 0x000C
|
||||
wmCtlColorStatic uint32 = 0x0138
|
||||
wmAppDone uint32 = 0x8001 // 다운로드 완료 시 사용하는 커스텀 메시지
|
||||
)
|
||||
|
||||
// ── 윈도우 스타일 상수 ───────────────────────────────────────
|
||||
|
||||
const (
|
||||
wsPopup uintptr = 0x80000000
|
||||
wsCaption uintptr = 0x00C00000
|
||||
wsSysMenu uintptr = 0x00080000
|
||||
wsChild uintptr = 0x40000000
|
||||
wsVisible uintptr = 0x10000000
|
||||
ssCenter uintptr = 0x00000001
|
||||
)
|
||||
|
||||
// ── 프로그레스바 상수 ────────────────────────────────────────
|
||||
|
||||
const (
|
||||
pbsSmooth uintptr = 0x01
|
||||
pbmSetRange32 uint32 = 0x0406
|
||||
pbmSetPos uint32 = 0x0402
|
||||
pbmSetBarColor uint32 = 0x0409
|
||||
pbmSetBkColor uint32 = 0x2001
|
||||
)
|
||||
|
||||
// ── 기타 Win32 상수 ──────────────────────────────────────────
|
||||
|
||||
const (
|
||||
setBkModeTransparent = 1
|
||||
|
||||
swShow = 5
|
||||
smCxScreen = 0
|
||||
smCyScreen = 1
|
||||
|
||||
mbOK uintptr = 0x00000000
|
||||
mbInfo uintptr = 0x00000040
|
||||
mbError uintptr = 0x00000010
|
||||
mbYesNo uintptr = 0x00000004
|
||||
mbQ uintptr = 0x00000020
|
||||
idYes = 6
|
||||
|
||||
iccProgressClass uint32 = 0x00000020
|
||||
)
|
||||
|
||||
// ── 색상 ─────────────────────────────────────────────────────
|
||||
|
||||
// rgb COLORREF(0x00BBGGRR) 값을 생성한다.
|
||||
func rgb(r, g, b uint8) uintptr {
|
||||
return uintptr(r) | (uintptr(g) << 8) | (uintptr(b) << 16)
|
||||
}
|
||||
|
||||
// 웹사이트 색상과 동일한 팔레트
|
||||
var (
|
||||
colorBg = rgb(46, 44, 47) // #2E2C2F
|
||||
colorText = rgb(200, 200, 200) // 밝은 회색
|
||||
colorAccent = rgb(186, 205, 176) // #BACDB0
|
||||
colorProgressBg = rgb(65, 63, 67) // bg보다 약간 밝은 색
|
||||
)
|
||||
|
||||
// ── DLL 및 프로시저 ──────────────────────────────────────────
|
||||
|
||||
var (
|
||||
user32 = windows.NewLazySystemDLL("user32.dll")
|
||||
kernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
||||
gdi32 = windows.NewLazySystemDLL("gdi32.dll")
|
||||
comctl32 = windows.NewLazySystemDLL("comctl32.dll")
|
||||
uxtheme = windows.NewLazySystemDLL("uxtheme.dll")
|
||||
)
|
||||
|
||||
// user32.dll
|
||||
var (
|
||||
messageBoxWProc = user32.NewProc("MessageBoxW")
|
||||
registerClassExWProc = user32.NewProc("RegisterClassExW")
|
||||
createWindowExWProc = user32.NewProc("CreateWindowExW")
|
||||
showWindowProc = user32.NewProc("ShowWindow")
|
||||
updateWindowProc = user32.NewProc("UpdateWindow")
|
||||
getMessageWProc = user32.NewProc("GetMessageW")
|
||||
translateMsgProc = user32.NewProc("TranslateMessage")
|
||||
dispatchMsgWProc = user32.NewProc("DispatchMessageW")
|
||||
sendMessageWProc = user32.NewProc("SendMessageW")
|
||||
postMessageWProc = user32.NewProc("PostMessageW")
|
||||
defWindowProcWProc = user32.NewProc("DefWindowProcW")
|
||||
destroyWindowProc = user32.NewProc("DestroyWindow")
|
||||
postQuitMsgProc = user32.NewProc("PostQuitMessage")
|
||||
getSystemMetricsProc = user32.NewProc("GetSystemMetrics")
|
||||
getDpiForSystemProc = user32.NewProc("GetDpiForSystem")
|
||||
setProcessDpiAwarenessContextProc = user32.NewProc("SetProcessDpiAwarenessContext")
|
||||
findWindowWProc = user32.NewProc("FindWindowW")
|
||||
setForegroundWindowProc = user32.NewProc("SetForegroundWindow")
|
||||
)
|
||||
|
||||
// kernel32.dll
|
||||
var (
|
||||
createMutexWProc = kernel32.NewProc("CreateMutexW")
|
||||
getModuleHandleWProc = kernel32.NewProc("GetModuleHandleW")
|
||||
)
|
||||
|
||||
// gdi32.dll
|
||||
var (
|
||||
createFontIndirectWProc = gdi32.NewProc("CreateFontIndirectW")
|
||||
createSolidBrushProc = gdi32.NewProc("CreateSolidBrush")
|
||||
setTextColorProc = gdi32.NewProc("SetTextColor")
|
||||
setBkModeProc = gdi32.NewProc("SetBkMode")
|
||||
deleteObjectProc = gdi32.NewProc("DeleteObject")
|
||||
)
|
||||
|
||||
// comctl32.dll / uxtheme.dll
|
||||
var (
|
||||
initCommonControlsExProc = comctl32.NewProc("InitCommonControlsEx")
|
||||
setWindowThemeProc = uxtheme.NewProc("SetWindowTheme")
|
||||
)
|
||||
|
||||
// ── Win32 구조체 ─────────────────────────────────────────────
|
||||
|
||||
type wndClassExW struct {
|
||||
cbSize uint32
|
||||
style uint32
|
||||
lpfnWndProc uintptr
|
||||
cbClsExtra int32
|
||||
cbWndExtra int32
|
||||
hInstance uintptr
|
||||
hIcon uintptr
|
||||
hCursor uintptr
|
||||
hbrBackground uintptr
|
||||
lpszMenuName *uint16
|
||||
lpszClassName *uint16
|
||||
hIconSm uintptr
|
||||
}
|
||||
|
||||
type msgW struct {
|
||||
hwnd uintptr
|
||||
message uint32
|
||||
wParam uintptr
|
||||
lParam uintptr
|
||||
time uint32
|
||||
ptX int32
|
||||
ptY int32
|
||||
}
|
||||
|
||||
type initCommonControlsExS struct {
|
||||
dwSize uint32
|
||||
dwICC uint32
|
||||
}
|
||||
|
||||
type logFontW struct {
|
||||
lfHeight int32
|
||||
lfWidth int32
|
||||
lfEscapement int32
|
||||
lfOrientation int32
|
||||
lfWeight int32
|
||||
lfItalic byte
|
||||
lfUnderline byte
|
||||
lfStrikeOut byte
|
||||
lfCharSet byte
|
||||
lfOutPrecision byte
|
||||
lfClipPrecision byte
|
||||
lfQuality byte
|
||||
lfPitchAndFamily byte
|
||||
lfFaceName [32]uint16
|
||||
}
|
||||
Reference in New Issue
Block a user