Skip to content

Instantly share code, notes, and snippets.

Created October 4, 2014 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/28e848db910f4c32c1e3 to your computer and use it in GitHub Desktop.
Save anonymous/28e848db910f4c32c1e3 to your computer and use it in GitHub Desktop.
// 17 july 2014
#include "winapi_windows.h"
#include "_cgo_export.h"
BOOL sharedWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
{
*lResult = (LRESULT) hollowBrush;
return TRUE;
}
// 12 july 2014
package ui
import (
"fmt"
)
// #cgo CFLAGS: --std=c99
// #cgo LDFLAGS: -luser32 -lkernel32 -lgdi32 -luxtheme -lmsimg32 -lcomdlg32
// #include "winapi_windows.h"
import "C"
//export xmissedmsg
func xmissedmsg(purpose *C.char, f *C.char, uMsg C.UINT) {
panic(fmt.Errorf("%s window procedure message %d does not return a value (bug in %s)", C.GoString(purpose), uMsg, C.GoString(f)))
}
// 17 july 2014
#include "winapi_windows.h"
HBRUSH hollowBrush;
DWORD initWindows(char **errmsg)
{
hollowBrush = GetStockObject(HOLLOW_BRUSH);
if (hollowBrush == NULL) {
*errmsg = "error getting hollow brush";
return GetLastError();
}
return 0;
}
// 17 july 2014
// cgo will include this file multiple times
#ifndef __GO_UI_WINAPI_WINDOWS_H__
#define __GO_UI_WINAPI_WINDOWS_H__
#define UNICODE
#define _UNICODE
#define STRICT
#define STRICT_TYPED_ITEMIDS
// get Windows version right; right now Windows XP
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#define _WIN32_WINDOWS 0x0501 /* according to Microsoft's winperf.h */
#define _WIN32_IE 0x0600 /* according to Microsoft's sdkddkver.h */
#define NTDDI_VERSION 0x05010000 /* according to Microsoft's sdkddkver.h */
#include <windows.h>
#include <commctrl.h>
#include <stdint.h>
#include <uxtheme.h>
#include <string.h>
#include <wchar.h>
#include <windowsx.h>
#include <vsstyle.h>
#include <vssym32.h>
// init_windows.c
extern HBRUSH hollowBrush;
extern DWORD initWindows(char **);
// common_windows.c
extern BOOL sharedWndProc(HWND, UINT, WPARAM, LPARAM, LRESULT *);
#endif
// 8 july 2014
package ui
// This file is called zz_test.go to keep it separate from the other files in this package (and because go test won't accept just test.go)
import (
"testing"
)
func TestDummy(t *testing.T) {
// do nothing
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment