Set the default control font on Windows to the expected standard font instead of to the default System font.

This commit is contained in:
Pietro Gagliardi 2014-02-24 14:49:46 -05:00
parent a9325fbfbc
commit 58f6bed7e4
1 changed files with 20 additions and 0 deletions

View File

@ -24,6 +24,7 @@ type classData struct {
xstyle uint32
mkid bool
altStyle uint32
font *_HANDLE
appendMsg uintptr
insertBeforeMsg uintptr
deleteMsg uintptr
@ -44,17 +45,20 @@ var classTypes = [nctypes]*classData{
name: "BUTTON",
style: _BS_PUSHBUTTON | controlstyle,
xstyle: 0 | controlxstyle,
font: &controlFont,
},
c_checkbox: &classData{
name: "BUTTON",
style: _BS_AUTOCHECKBOX | controlstyle,
xstyle: 0 | controlxstyle,
font: &controlFont,
},
c_combobox: &classData{
name: "COMBOBOX",
style: _CBS_DROPDOWNLIST | _WS_VSCROLL | controlstyle,
xstyle: 0 | controlxstyle,
altStyle: _CBS_DROPDOWN | _CBS_AUTOHSCROLL | _WS_VSCROLL | controlstyle,
font: &controlFont,
appendMsg: _CB_ADDSTRING,
insertBeforeMsg: _CB_INSERTSTRING,
deleteMsg: _CB_DELETESTRING,
@ -66,11 +70,13 @@ var classTypes = [nctypes]*classData{
name: "EDIT",
style: _ES_AUTOHSCROLL | _WS_BORDER | controlstyle,
xstyle: 0 | controlxstyle,
font: &controlFont,
},
c_label: &classData{
name: "STATIC",
style: _SS_NOPREFIX | controlstyle,
xstyle: 0 | controlxstyle,
font: &controlFont,
},
c_listbox: &classData{
name: "LISTBOX",
@ -78,6 +84,7 @@ var classTypes = [nctypes]*classData{
style: _WS_VSCROLL | controlstyle,
xstyle: 0 | controlxstyle,
altStyle: _LBS_EXTENDEDSEL | _WS_VSCROLL | controlstyle,
font: &controlFont,
appendMsg: _LB_ADDSTRING,
insertBeforeMsg: _LB_INSERTSTRING,
deleteMsg: _LB_DELETESTRING,
@ -151,6 +158,19 @@ func (s *sysData) make(initText string, window *sysData) (err error) {
return fmt.Errorf("error actually creating window/control: %v", r.err)
}
s.hwnd = _HWND(r.ret)
if ct.font != nil {
uitask <- &uimsg{
call: _sendMessage,
p: []uintptr{
uintptr(s.hwnd),
uintptr(_WM_SETFONT),
uintptr(_WPARAM(*ct.font)),
uintptr(_LPARAM(_TRUE)),
},
ret: ret,
}
<-ret
}
return nil
}