From bcc8751c8ba5f54d5da74aa7e38741dadd62fea8 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 10 Feb 2014 17:10:47 -0500 Subject: [PATCH] Added a checkbox to the example window. --- main.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 71defba..9a425b6 100644 --- a/main.go +++ b/main.go @@ -26,6 +26,7 @@ const ( IDC_EDIT IDC_LIST IDC_LABEL + IDC_CHECK ) var varCombo, fixCombo, edit, list HWND @@ -68,14 +69,20 @@ func wndProc(hwnd HWND, msg uint32, wParam WPARAM, lParam LPARAM) LRESULT { } // TODO get text from index + checkState, err := IsDlgButtonChecked(hwnd, IDC_CHECK) + if err != nil { + fatalf("error getting checkbox check state: %v", err) + } + MessageBox(hwnd, fmt.Sprintf("button state: %s\n" + "variable combo box text: %s\n" + "fixed combo box text with WM_GETTEXT: %s\n" + "fixed combo box current index: %d\n" + "edit field text: %s\n" + - "list box current index: %d\n", - buttonclick, varText, fixTextWM, fixTextIndex, editText, listIndex), + "list box current index: %d\n" + + "check box checked: %v\n", + buttonclick, varText, fixTextWM, fixTextIndex, editText, listIndex, checkState == BST_CHECKED), "note", MB_OK) } @@ -232,6 +239,16 @@ func main() { fatalf("error creating label: %v", err) } + _, err = CreateWindowEx( + 0, + "BUTTON", "Checkbox", + BS_AUTOCHECKBOX | controlStyle, + 140, 110, 100, 20, + hwnd, HMENU(IDC_CHECK), hInstance, NULL) + if err != nil { + fatalf("error creating checkbox: %v", err) + } + _, err = ShowWindow(hwnd, nCmdShow) if err != nil { fatalf("error showing window: %v", err)