예제 #1
0
HMENU WINAPI CreateCombinedMenu(TMenuItem *pMenuItem, DWORD dwItemCount, BOOL bPopup)
{
    HMENU hMenu, hSubMenu;

    if (pMenuItem == NULL || dwItemCount == 0)
        return NULL;

    hMenu = bPopup ? CreatePopupMenu() : CreateMenu();
    if (hMenu == NULL)
        return hMenu;

    for (DWORD i = 0; i != dwItemCount; ++i)
    {
        if (pMenuItem[i].uFlags & MF_POPUP)
        {
            hSubMenu = CreateCombinedMenu(pMenuItem[i].pSubMenuItem, pMenuItem[i].dwSubMenuCount, True);
            if (hSubMenu)
            {
                AppendMenuA(hMenu, pMenuItem[i].uFlags, (UINT)hSubMenu, pMenuItem[i].lpNewItem);
            }
        }
        else
        {
            AppendMenuA(hMenu, pMenuItem[i].uFlags, pMenuItem[i].uIDNewItem, pMenuItem[i].lpNewItem);
        }
    }

    return hMenu;
}
예제 #2
0
void InitGlobals() {
	g_dat = (struct GlobalMessageData *)malloc(sizeof(struct GlobalMessageData));
	g_dat->hMessageWindowList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
	g_dat->hParentWindowList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
    g_dat->hMenuANSIEncoding = CreatePopupMenu();
    AppendMenuA(g_dat->hMenuANSIEncoding, MF_STRING, 500, Translate("Default codepage"));
    AppendMenuA(g_dat->hMenuANSIEncoding, MF_SEPARATOR, 0, 0);
    EnumSystemCodePagesA(LangAddCallback, CP_INSTALLED);
	g_hAck = HookEvent(ME_PROTO_ACK, ackevent);
	ReloadGlobals();
	g_dat->hParent = NULL;
	g_dat->protoNum = 0;
	g_dat->protoNames = NULL;
	g_dat->hIconList = NULL;
}
예제 #3
0
void VDAppendMenuW32(HMENU hmenu, UINT flags, UINT id, const wchar_t *text){
	if (VDIsWindowsNT()) {
		AppendMenuW(hmenu, flags, id, text);
	} else {
		AppendMenuA(hmenu, flags, id, VDTextWToA(text).c_str());
	}
}
예제 #4
0
void com_wise_sys_Win32Peer::showContextMenu(
	javax_microedition_lcdui_Command_ap  aCommand1,
	jint  x,
	jint  y
) {
	if (aCommand1 == FASTIVA_NULL) {
		return;
	}

	MainFrame* pFrame = (MainFrame*)this->m_handle;
	HMENU hMenu = ::CreatePopupMenu();//
	pFrame->m_hPopupMenu = hMenu;
	for (int i = 0; i < aCommand1->length(); i ++) {
		Byte_A::Buffer cmd(aCommand1->get$(i)->getLabel()->getBytes());
		AppendMenuA(hMenu, MF_STRING, i, (char*)(jbyte*)cmd);
	}
	TrackPopupMenu(
		hMenu,
		TPM_LEFTALIGN,
		x,
		y,
		0,
		*pFrame,
		NULL
	);
}
예제 #5
0
void adjust_monst_menu() {
	if(menuHandle == NULL) return;
	short i, monst_pos = 0;
	HMENU monst_menu;

	if(overall_mode == MODE_STARTUP) return;

	monst_menu = GetSubMenu(menuHandle, MONST_MENU_POS);
	for(i = 0; i < 256; i++) {
		on_monst_menu[i] = -1;
	}
	for(i = 1; i < 256; i++) {
		if(i == 1 || univ.party.m_noted.count(i) > 0) {
			on_monst_menu[monst_pos] = i;
			monst_pos++;
		}
	}

	while(GetMenuItemCount(monst_menu) > 2) {
		RemoveMenu(monst_menu, 2, MF_BYPOSITION);
	}
	for(i = 0; i < 256; i++) {
		if(on_monst_menu[i] >= 0) {
			std::string monst_name = univ.scenario.scen_monsters[on_monst_menu[i]].m_name;
			AppendMenuA(monst_menu, MF_STRING | MF_ENABLED, 1000 + i, monst_name.c_str());
		}
	}
	DrawMenuBar(mainPtr.getSystemHandle());
}
예제 #6
0
static BOOL CALLBACK LangAddCallback(CHAR * str) {
	int i, count;
	UINT cp;
	static struct { UINT cpId; char *cpName; } cpTable[] = {
		{	874,	"Thai" },
		{	932,	"Japanese" },
		{	936,	"Simplified Chinese" },
		{	949,	"Korean" },
		{	950,	"Traditional Chinese" },
		{	1250,	"Central European" },
		{	1251,	"Cyrillic" },
		{	1252,	"Latin I" },
		{	1253,	"Greek" },
		{	1254,	"Turkish" },
		{	1255,	"Hebrew" },
		{	1256,	"Arabic" },
		{	1257,	"Baltic" },
		{	1258,	"Vietnamese" },
		{	1361,	"Korean (Johab)" }
	};
    cp = atoi(str);
	count = sizeof(cpTable)/sizeof(cpTable[0]);
	for (i=0; i<count && cpTable[i].cpId!=cp; i++);
	if (i < count) {
        AppendMenuA(g_dat->hMenuANSIEncoding, MF_STRING, cp, Translate(cpTable[i].cpName));
	}
	return TRUE;
}
예제 #7
0
	static bool LuaGuiAppendMenu(void *hMenu, uint32_t flag, UINT_PTR newItemId, const char *newItemName)
	{
		return !! AppendMenuA(
			reinterpret_cast<HMENU>(hMenu),
			flag,
			newItemId,
			newItemName);
	}
예제 #8
0
bool VDAppendPopupMenuW32(HMENU hmenu, UINT flags, HMENU hmenuPopup, const wchar_t *text){
	flags |= MF_POPUP;

	if (VDIsWindowsNT())
		return 0 != AppendMenuW(hmenu, flags, (UINT_PTR)hmenuPopup, text);
	else
		return 0 != AppendMenuA(hmenu, flags, (UINT_PTR)hmenuPopup, VDTextWToA(text).c_str());
}
예제 #9
0
파일: menus.c 프로젝트: Bgods/r-source
BOOL myAppendMenu(HMENU h, UINT flags, UINT_PTR id, LPCTSTR name)
{
    if(localeCP > 0 && (localeCP != GetACP())) {
	wchar_t wc[100];
	mbstowcs(wc, name, 100);
	return AppendMenuW(h, flags, id, wc);
    } else
	return AppendMenuA(h, flags, id, name);
}
예제 #10
0
	//=============================================================================================================
	size_t CMenuStrip::AddSeparator(size_t menuid)
	{
		// TODO: errorhandling
		popupmenu& pm = submenus[menuid];
		pm.ids[pm.items] = GenerateID();

		AppendMenuA(pm.handle, MF_SEPARATOR, (UINT_PTR)pm.ids[pm.items], 0);
		++pm.items;

		return pm.items;
	}
예제 #11
0
	//=============================================================================================================
	size_t CMenuStrip::AddItem(size_t menuid, const std::string& text)
	{
		// TODO: errorhandling
		popupmenu& pm = submenus[menuid];
		pm.ids[pm.items] = GenerateID();
		
		AppendMenuA(pm.handle, MF_STRING, (UINT_PTR)pm.ids[pm.items], text.c_str());
		++pm.items;

		return pm.items;
	}
예제 #12
0
static void
setMenuItem(GLUTmenuItem * item, const char *label,
	    int value, Bool isTrigger)
{
  GLUTmenu *menu;

  menu = item->menu;
  item->label = __glutStrdup(label);
  if (!item->label) {
    __glutFatalError("out of memory.");
  }
  item->isTrigger = isTrigger;
  item->len = (int) strlen(label);
  item->value = value;
  item->unique = uniqueMenuHandler++;
  if (isTrigger) {
    AppendMenuA((HMENU) menu->win, MF_POPUP, (UINT)item->win, label);
  } else {
    AppendMenuA((HMENU) menu->win, MF_STRING, item->unique, label);
  }
}
예제 #13
0
LRESULT CWindow::OnCreate(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    HDC hDC;
    static CHAR szMenuText[] = "&Exit";
    TEXTMETRIC TextMetrics;

    hDC = GetDC(hWnd);
    m_hFont = CreateFont(15, 0, 0, 0, FW_NORMAL, 0, 0, 0,
        GB2312_CHARSET, 0, 0, CLEARTYPE_QUALITY, DEFAULT_PITCH, "Tahoma");
    GetTextMetrics(hDC, &TextMetrics);
    iVScrollPos = 0;
    cxChar = TextMetrics.tmAveCharWidth;
    cyChar = TextMetrics.tmHeight + TextMetrics.tmExternalLeading;
    cxCaps = (TextMetrics.tmPitchAndFamily & 1) ? (int)(cxChar + cxChar / 2) : cxChar;

    m_hMenu = CreateMenu();
    m_hMenuPopup = CreatePopupMenu();

    MENUITEMINFOA mii = { sizeof(mii) };

    mii.fMask = MIIM_ID;
    mii.fType = MFT_STRING;
    mii.dwTypeData = szMenuText;
    mii.fState = MF_ENABLED;
    mii.wID = IDM_EXIT;
    mii.cch = sizeof(szMenuText) - 1;

    AppendMenuA(m_hMenuPopup, MF_ENABLED, IDM_EXIT, szMenuText);
    AppendMenuA(m_hMenu, MF_POPUP, (UINT)m_hMenuPopup, "&File");

    if (SetMenu(hWnd, m_hMenu) == False)
    {
//        MessageBoxErrorW(hWnd, GetLastError(), NULL, 64);
    }

    ReleaseDC(hWnd, hDC);

    return ERROR_SUCCESS;
}
예제 #14
0
	//=============================================================================================================
	bool CMenuStrip::Initialize(HWND parent)
	{
		if( hmenu )
			return true;

		CWindow::Initialize(parent);
		hmenu = CreateMenu();

		for( size_t i = 0; i < submenus.size(); ++i )
		{
			popupmenu& pm = submenus[i];
			AppendMenuA(hmenu, MF_STRING|MF_POPUP, (UINT)pm.handle, pm.text.c_str());
		}

		SetMenu(parent, hmenu);
		return (hmenu != NULL);
	}
예제 #15
0
void InitGlobals() {
	g_dat = (struct GlobalMessageData *)mir_alloc(sizeof(struct GlobalMessageData));
	g_dat->hMessageWindowList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
	g_dat->hParentWindowList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
    g_dat->hMenuANSIEncoding = CreatePopupMenu();
    AppendMenu(g_dat->hMenuANSIEncoding, MF_STRING, 500, TranslateT("Default codepage"));
    AppendMenuA(g_dat->hMenuANSIEncoding, MF_SEPARATOR, 0, 0);
    EnumSystemCodePagesA(LangAddCallback, CP_INSTALLED);
	g_hAck = HookEvent(ME_PROTO_ACK, ackevent);
	ReloadGlobals();
	g_dat->lastParent = NULL;
	g_dat->lastChatParent = NULL;
	g_dat->protoNum = 0;
	g_dat->protoNames = NULL;
	g_dat->hTabIconList = NULL;
	g_dat->hButtonIconList = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, (g_dat->protoNum + 1) * 12 + 8, 0);
	g_dat->draftList = NULL;
}
예제 #16
0
/**
* Similar to AppendMenuW() Win32 Base API (user32.dll),
* except that it will work also on Win9x/ME without MSLU support.
*/
UAWIN32API  BOOL
WINAPI      UAppendMenu(
    HMENU      hMenu,
    UINT       uFlags,
    UINT       uIDNewItem,
    LPCWSTR    lpcwszNewItem)   /*UTF-16 IN*/
{
    static BOOL bDisable_AppendMenuW = FALSE;
    if (!bDisable_AppendMenuW &&
        isWin32UnicodeAPIsSupported()) {
        typedef BOOL
            (WINAPI *FARPROC_AppendMenuW)(
            HMENU       hMenu,
            UINT        uFlags,
            UINT        uIDNewItem,
            LPCWSTR     lpcwszNewItem); /*UTF-16 IN*/
        static FARPROC_AppendMenuW farproc_AppendMenuW =
            (FARPROC_AppendMenuW)NULL;

        if (farproc_AppendMenuW == (FARPROC_AppendMenuW)NULL) {
            HMODULE hModule = GetModuleHandleA("user32.dll");
            farproc_AppendMenuW = (FARPROC_AppendMenuW)
                GetProcAddress(hModule, "AppendMenuW");
        }
        if (farproc_AppendMenuW != (FARPROC_AppendMenuW)NULL) {
            return (*farproc_AppendMenuW)(
                hMenu,
                uFlags,
                uIDNewItem,
                lpcwszNewItem);  /*UTF-16 IN*/
        }
        bDisable_AppendMenuW = TRUE;
    }
    /* Convert UTF-16 input strings to ANSI */
    LPCWSTR_TO_LPSTR(lpcwszNewItem,
        return FALSE
        );
    /* Execute the ANSI API */
    return AppendMenuA(
        hMenu,
        uFlags,
        uIDNewItem,
        (LPCSTR)lpcwszNewItem); /*ANSI IN*/
}
예제 #17
0
int IconPressed(WPARAM wParam, LPARAM lParam) {
	StatusIconClickData *cd = (StatusIconClickData *)lParam;
	if(strcmp(cd->szModule, MODULE) != 0) return 0;

	HANDLE hContact = (HANDLE)wParam, hSub;
	if(ServiceExists(MS_MC_GETMOSTONLINECONTACT) && (hSub = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
		hContact = hSub;

	if(!CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)MODULE))
		return 0;

	HMENU hMenu = CreatePopupMenu();
	for(int i = 0; zap_array[i]; i++) {
		AppendMenuA(hMenu,MF_STRING,i+1, Translate(zap_array[i]));
	}	
	BOOL cmd = TrackPopupMenu(hMenu, TPM_NONOTIFY | TPM_RETURNCMD, cd->clickLocation.x, cd->clickLocation.y, 0, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), 0);
	DestroyMenu(hMenu);

	if(cmd) {
		int zap_num = cmd - 1;
		NotifyZapSend(hContact, zap_num);
	}
	return 0;
}
예제 #18
0
/* Show the window */
int text_create(TW *tw, const char *app_name, int show_cmd)
{
    HMENU sysmenu;
    HINSTANCE hInstance = GetModuleHandle(NULL);
#ifndef WINDOWS_NO_UNICODE
    wchar_t *app_nameW, *d;
    const char *s;

    app_nameW = malloc(strlen(app_name)*2+2);
    if (app_nameW == NULL) {
        text_error("Out of memory");
        return 1;
    }
    d = app_nameW;
    s = app_name;
    while ((*d++ = (wchar_t)(unsigned char)(*s++)) != 0);
    tw->TitleW = app_nameW;
#endif

    tw->Title = app_name;
    tw->nCmdShow = show_cmd;
    tw->quitnow = FALSE;

    /* make sure we have some sensible defaults */
    if (tw->KeyBufSize < 256)
        tw->KeyBufSize = 256;

    tw->CursorPos.x = tw->CursorPos.y = 0;
    tw->bFocus = FALSE;
    tw->bGetCh = FALSE;
    tw->CaretHeight = 0;

    /* allocate buffers */
    tw->KeyBufIn = tw->KeyBufOut = tw->KeyBuf = malloc(tw->KeyBufSize);
    if (tw->KeyBuf == NULL) {
        text_error("Out of memory");
        return 1;
    }
    tw->ScreenBuffer = malloc(tw->ScreenSize.x * tw->ScreenSize.y * CHARSIZE);
    if (tw->ScreenBuffer == NULL) {
        text_error("Out of memory");
        return 1;
    }
#ifdef WINDOWS_NO_UNICODE
    memset(tw->ScreenBuffer, ' ', tw->ScreenSize.x * tw->ScreenSize.y);
#else
    wmemset(tw->ScreenBuffer, ' ', tw->ScreenSize.x * tw->ScreenSize.y);
#endif

#ifdef WINDOWS_NO_UNICODE
    tw->hwnd = CreateWindow(TextWinClassName, tw->Title,
                  WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL,
                  tw->x, tw->y, tw->cx, tw->cy,
                  NULL, NULL, hInstance, tw);
#else
    tw->hwnd = CreateWindowW(TextWinClassName, app_nameW,
                  WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL,
                  tw->x, tw->y, tw->cx, tw->cy,
                  NULL, NULL, hInstance, tw);
#endif

    if (tw->hwnd == NULL) {
        MessageBoxA((HWND)NULL,"Couldn't open text window",(LPSTR)NULL, MB_ICONHAND | MB_SYSTEMMODAL);
        return 1;
    }

    ShowWindow(tw->hwnd, tw->nCmdShow);
    sysmenu = GetSystemMenu(tw->hwnd,0);	/* get the sysmenu */
    AppendMenu(sysmenu, MF_SEPARATOR, 0, NULL);
    AppendMenuA(sysmenu, MF_STRING, M_COPY_CLIP, "Copy to Clip&board");
    AppendMenuA(sysmenu, MF_STRING, M_PASTE_CLIP, "&Paste");

    return 0;
}
예제 #19
0
파일: kbswitch2.c 프로젝트: ambyte/kbswitch
static void DoPopupMenu(void)
{
	int idLayoutsBegin,idLayoutsEnd,idExit,cmd;
	POINT mpt;
	HMENU hMenu=CreatePopupMenu();
	Layout *pFirstLayout=CreateLayoutsList();

	SetForegroundWindow(g_hWnd);

	// Fill menu
	{
		int id=1;

		idLayoutsBegin=id;
		if(pFirstLayout)
		{
			Layout *pActiveLayout=FindActiveLayout(pFirstLayout),*pLayout;

			for(pLayout=pFirstLayout;pLayout;pLayout=pLayout->pNextLayout)
			{
				UINT flags=0;

				if(pLayout==pActiveLayout)
					flags|=MF_CHECKED;

				AppendMenuW(hMenu,flags,id++,pLayout->pDisplayName);
			}

			AppendMenuW(hMenu,MF_SEPARATOR,0,0);
		}
		idLayoutsEnd=id;

		idExit=id++;
		AppendMenuA(hMenu,0,idExit,"E&xit");
	}

	// Popup menu
	GetCursorPos(&mpt);
	cmd=TrackPopupMenuEx(hMenu,TPM_RETURNCMD,mpt.x,mpt.y,g_hWnd,0);

	// Do what?
	if(cmd==idExit)
	{
		// Bye...
		PostQuitMessage(0);
	}
	else if(cmd>=idLayoutsBegin&&cmd<idLayoutsEnd)
	{
		// Set new layout
		int idx=cmd-idLayoutsBegin;
		Layout *pLayout=pFirstLayout;

		while(idx-->0)
			pLayout=pLayout->pNextLayout;

		SetLayoutByHandle(pLayout->hkl,FALSE);
	}

	DeleteLayoutList(pFirstLayout);
	pFirstLayout=NULL;
}
예제 #20
0
static INT_PTR CALLBACK SkinEdit_ExtBkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	SKINDESCRIPTION *psd = (SKINDESCRIPTION *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
	if (psd) {
		ID_EXTBK_FIRST = psd->firstItem;
		ID_EXTBK_LAST = psd->lastItem;
		StatusItems = psd->StatusItems;
	}

	switch (msg) {
	case WM_INITDIALOG:
		psd = (SKINDESCRIPTION *)malloc(sizeof(SKINDESCRIPTION));
		if (psd == NULL)
			return FALSE;
		memset(psd, 0, sizeof(SKINDESCRIPTION));
		memcpy(psd, (void *)lParam, sizeof(SKINDESCRIPTION));
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)psd);

		ID_EXTBK_FIRST = psd->firstItem;
		ID_EXTBK_LAST = psd->lastItem;
		StatusItems = psd->StatusItems;

		TranslateDialogDefault(hwndDlg);
		FillItemList(hwndDlg);
		SendMessage(hwndDlg, WM_USER + 101, 0, 0);

		psd->hMenuItems = CreatePopupMenu();
		AppendMenu(psd->hMenuItems, MF_STRING | MF_DISABLED, (UINT_PTR)0, LPGENT("Copy from"));
		AppendMenuA(psd->hMenuItems, MF_SEPARATOR, (UINT_PTR)0, NULL);

		{
			for (int i = ID_EXTBK_FIRST; i < ID_EXTBK_LAST; i++) {
				int iOff = StatusItems[i - ID_EXTBK_FIRST]->szName[0] == '{' ? 3 : 0;
				if (iOff)
					AppendMenuA(psd->hMenuItems, MF_SEPARATOR, (UINT_PTR)0, NULL);
				AppendMenuA(psd->hMenuItems, MF_STRING, (UINT_PTR)i, &StatusItems[i - ID_EXTBK_FIRST]->szName[iOff]);
			}
		}
		return TRUE;

	case WM_USER + 101:
		SendDlgItemMessage(hwndDlg, IDC_MRGN_LEFT_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
		SendDlgItemMessage(hwndDlg, IDC_MRGN_TOP_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
		SendDlgItemMessage(hwndDlg, IDC_MRGN_RIGHT_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
		SendDlgItemMessage(hwndDlg, IDC_MRGN_BOTTOM_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
		SendDlgItemMessage(hwndDlg, IDC_ALPHASPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));

		SendDlgItemMessage(hwndDlg, IDC_BORDERTYPE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("<None>"));
		SendDlgItemMessage(hwndDlg, IDC_BORDERTYPE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Raised"));
		SendDlgItemMessage(hwndDlg, IDC_BORDERTYPE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Sunken"));
		SendDlgItemMessage(hwndDlg, IDC_BORDERTYPE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Bumped"));
		SendDlgItemMessage(hwndDlg, IDC_BORDERTYPE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Etched"));

		SendDlgItemMessage(hwndDlg, IDC_3DDARKCOLOR, CPM_SETCOLOUR, 0, db_get_dw(NULL, "CLCExt", "3ddark", RGB(224,224,224)));
		SendDlgItemMessage(hwndDlg, IDC_3DLIGHTCOLOR, CPM_SETCOLOUR, 0, db_get_dw(NULL, "CLCExt", "3dbright", RGB(224,224,224)));
		return 0;

	case WM_DRAWITEM:
		{
			DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *) lParam;
			int iItem = dis->itemData;
			StatusItems_t *item = 0;

			SetBkMode(dis->hDC, TRANSPARENT);
			FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_WINDOW));

			if (iItem >= ID_EXTBK_FIRST && iItem < ID_EXTBK_LAST)
				item = StatusItems[iItem - ID_EXTBK_FIRST];

			if (dis->itemState & ODS_SELECTED && iItem != ID_EXTBKSEPARATOR) {
				FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
				SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
			}
			else {
				FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_WINDOW));
				if (item && item->IGNORED)
					SetTextColor(dis->hDC, RGB(255, 0, 0));
				else
					SetTextColor(dis->hDC, GetSysColor(COLOR_WINDOWTEXT));
			}
			if (iItem == ID_EXTBKSEPARATOR) {
				HPEN hPen, hPenOld;
				POINT pt;

				hPen = CreatePen(PS_SOLID, 2, GetSysColor(COLOR_WINDOWTEXT));
				hPenOld = (HPEN)SelectObject(dis->hDC, hPen);

				MoveToEx(dis->hDC, dis->rcItem.left, (dis->rcItem.top + dis->rcItem.bottom) / 2, &pt);
				LineTo(dis->hDC, dis->rcItem.right, (dis->rcItem.top + dis->rcItem.bottom) / 2);
				SelectObject(dis->hDC, hPenOld);
				DeleteObject((HGDIOBJ)hPen);
			}
			else if (item) {
				char *szName = item->szName[0] == '{' ? &item->szName[3] : item->szName;

				TextOutA(dis->hDC, dis->rcItem.left, dis->rcItem.top, szName, mir_strlen(szName));
			}
			return TRUE;
		}

	case WM_CONTEXTMENU:
		{
			HWND hwndList = GetDlgItem(hwndDlg, IDC_ITEMS);

			POINT pt;
			GetCursorPos(&pt);

			RECT rc;
			GetWindowRect(hwndList, &rc);

			if (PtInRect(&rc, pt)) {
				int iSelection = (int)TrackPopupMenu(psd->hMenuItems, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);

				if (iSelection >= ID_EXTBK_FIRST && iSelection < ID_EXTBK_LAST) {
					iSelection -= ID_EXTBK_FIRST;
					StatusItems_t *pSel = StatusItems[iSelection];

					for(int i = ID_EXTBK_FIRST; i < ID_EXTBK_LAST; i++) {
						if ( SendMessage(hwndList, LB_GETSEL, i - ID_EXTBK_FIRST, 0) <= 0)
							continue;

						int iIndex = SendMessage(hwndList, LB_GETITEMDATA, i - ID_EXTBK_FIRST, 0);
						iIndex -= ID_EXTBK_FIRST;
						if (iIndex < 0)
							continue;

						StatusItems_t *p = StatusItems[iIndex];
						p->ALPHA = pSel->ALPHA;
						p->BORDERSTYLE = pSel->BORDERSTYLE;
						p->COLOR = pSel->COLOR;
						p->COLOR2 = pSel->COLOR2;
						p->COLOR2_TRANSPARENT = pSel->COLOR2_TRANSPARENT;
						p->CORNER = pSel->CORNER;
						p->GRADIENT = pSel->GRADIENT;
						p->IGNORED = pSel->IGNORED;
						p->imageItem = pSel->imageItem;
						p->MARGIN_BOTTOM = pSel->MARGIN_BOTTOM;
						p->MARGIN_LEFT = pSel->MARGIN_LEFT;
						p->MARGIN_RIGHT = pSel->MARGIN_RIGHT;
						p->MARGIN_TOP = pSel->MARGIN_TOP;
						p->TEXTCOLOR = pSel->TEXTCOLOR;
					}
					OnListItemsChange(hwndDlg);
				}
			}
		}
		break;

	case WM_COMMAND:
		// this will check if the user changed some actual statusitems values
		// if yes the flag bChanged will be set to TRUE
		SetChangedStatusItemFlag(wParam, hwndDlg);
		switch(LOWORD(wParam)) {
		case IDC_ITEMS:
			if (HIWORD(wParam) != LBN_SELCHANGE)
				return FALSE;
			{
				int iItem = SendDlgItemMessage(hwndDlg, IDC_ITEMS, LB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_ITEMS, LB_GETCURSEL, 0, 0), 0);
				if (iItem == ID_EXTBKSEPARATOR)
					return FALSE;
			}
			OnListItemsChange(hwndDlg);
			if (psd->pfnClcOptionsChanged)
				psd->pfnClcOptionsChanged();
			break;
		case IDC_GRADIENT:
			ReActiveCombo(hwndDlg);
			break;
		case IDC_CORNER:
			ReActiveCombo(hwndDlg);
			break;
		case IDC_IGNORE:
			ReActiveCombo(hwndDlg);
			break;
		case IDC_COLOR2_TRANSPARENT:
			ReActiveCombo(hwndDlg);
			break;
		case IDC_BORDERTYPE:
			break;
		}
		if ((LOWORD(wParam) == IDC_ALPHA || LOWORD(wParam) == IDC_MRGN_LEFT || LOWORD(wParam) == IDC_MRGN_BOTTOM || LOWORD(wParam) == IDC_MRGN_TOP || LOWORD(wParam) == IDC_MRGN_RIGHT) && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()))
			return 0;
		SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR) lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR) lParam)->code) {
			case PSN_APPLY:
				// save user made changes
				SaveLatestChanges(hwndDlg);
				// save struct to DB
				if (psd->pfnSaveCompleteStruct)
					psd->pfnSaveCompleteStruct();
				db_set_dw(NULL, "CLCExt", "3dbright", SendDlgItemMessage(hwndDlg, IDC_3DLIGHTCOLOR, CPM_GETCOLOUR, 0, 0));
				db_set_dw(NULL, "CLCExt", "3ddark", SendDlgItemMessage(hwndDlg, IDC_3DDARKCOLOR, CPM_GETCOLOUR, 0, 0));

				if (psd->pfnClcOptionsChanged)
					psd->pfnClcOptionsChanged();
				if (psd->hwndCLUI) {
					SendMessage(psd->hwndCLUI, WM_SIZE, 0, 0);
					PostMessage(psd->hwndCLUI, WM_USER+100, 0, 0);		// CLUIINTM_REDRAW
				}
				break;
			}
		}
		break;
	case WM_DESTROY:
		DestroyMenu(psd->hMenuItems);
		break;
	case WM_NCDESTROY:
		free(psd);
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
		break;
	}
	return FALSE;
}
예제 #21
0
void MusPlayer_WinAPI::initUI(HWND hWnd)
{
    HGDIOBJ hFont   = GetStockObject(DEFAULT_GUI_FONT);
    HFONT hFontBold = CreateFontW(-11, 0, 0, 0, FW_BOLD, FALSE, FALSE,
                                0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
                               CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
                               DEFAULT_PITCH | FF_SWISS, L"Tahoma");
    int left = 5;
    int top = 10;

    HWND hText = CreateWindowExW(0, L"STATIC", L"Press \"Open\" or drag&&drop music file into this window",
                                WS_CHILD | WS_VISIBLE | SS_LEFT,
                                left, top, 400, 15,
                                hWnd, NULL, m_hInstance, NULL);
    top += 25;

    m_labelTitle = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                left, top, 400, 15,
                                hWnd, NULL, m_hInstance, NULL);
    top += 15;
    m_labelArtist = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                left, top, 400, 15,
                                hWnd, NULL, m_hInstance, NULL);
    top += 15;
    m_labelAlboom = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                left, top, 400, 15,
                                hWnd, NULL, m_hInstance, NULL);
    top += 15;
    m_labelCopyright = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                left, top, 400, 15,
                                hWnd, NULL, m_hInstance, NULL);
    top += 15;


    m_buttonOpen = CreateWindowExW(0, L"BUTTON", L"Open", WS_TABSTOP|WS_VISIBLE|WS_CHILD,
                                left, top, 60, 21, hWnd,
                                (HMENU)CMD_Open, // Here is the ID of your button ( You may use your own ID )
                                m_hInstance, NULL);
    left += 60;

    m_buttonPlay = CreateWindowExW(0, L"BUTTON", L"Play/Pause", WS_TABSTOP|WS_VISIBLE|WS_CHILD,
                                left, top, 60, 21, hWnd,
                                (HMENU)CMD_Play, // Here is the ID of your button ( You may use your own ID )
                                m_hInstance, NULL);
    left += 60;

    m_buttonStop = CreateWindowExW(0, L"BUTTON", L"Stop", WS_TABSTOP|WS_VISIBLE|WS_CHILD,
                                left, top, 60, 21, hWnd,
                                (HMENU)CMD_Stop, // Here is the ID of your button ( You may use your own ID )
                                m_hInstance, NULL);

    left += 60;
    m_volume    = CreateWindowExW(0, TRACKBAR_CLASS, L"Volume", WS_TABSTOP|WS_VISIBLE|WS_CHILD,
                                  left, top-2, 80, 25, hWnd,
                                  (HMENU)CMD_Volume, // Here is the ID of your button ( You may use your own ID )
                                  m_hInstance, NULL);
    SendMessageW(m_volume, TBM_SETRANGE,
                (WPARAM)TRUE,               //redraw flag
                (LPARAM)MAKELONG(0, 128));  //min. & max. positions
    SendMessageW(m_volume, TBM_SETPOS,
                (WPARAM)TRUE,               //redraw flag
                (LPARAM)128);
    SendMessageW(m_volume, WM_SETFONT, (WPARAM)hFont, 0);
    left += 80;

    m_formatInfo = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                   left, top, 200, 15,
                                   hWnd, NULL, m_hInstance, NULL);
    SendMessageW(m_formatInfo, WM_SETFONT, (WPARAM)hFont, 0);

    left = 5;
    top += 21;

    m_recordWave = CreateWindowExW(0, L"BUTTON", L"Record wave", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX,
                                                             left, top, 200, 15,
                                                             hWnd, (HMENU)CMD_RecordWave, m_hInstance, NULL);
    SendMessageW(m_recordWave, WM_SETFONT, (WPARAM)hFont, 0);
    CheckDlgButton(m_groupADLMIDI, CMD_RecordWave, BST_UNCHECKED);

    top += 18;

    WNDPROC OldBtnProc;

    m_groupGME = CreateWindowExW(0, L"BUTTON", L"Game Music Emulators setup", WS_VISIBLE | WS_CHILD | BS_GROUPBOX,
                                left, top, 330, 50, hWnd, (HMENU)GRP_GME, m_hInstance, NULL);
    SendMessageW(m_groupGME, WM_SETFONT, (WPARAM)hFont, 0);
    OldBtnProc = reinterpret_cast<WNDPROC>(static_cast<LONG_PTR>(
                 SetWindowLongPtr(m_groupGME, GWLP_WNDPROC,
                 reinterpret_cast<LONG_PTR>(MusPlayer_WinAPI::SubCtrlProc))) );
    SetWindowLongPtr(m_groupGME, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(OldBtnProc));

    m_gme.m_labelTrack = CreateWindowExW(0, L"STATIC", L"Track number:", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                10, 20, 70, 15,
                                 m_groupGME, NULL, m_hInstance, NULL);
    SendMessageW(m_gme.m_labelTrack, WM_SETFONT, (WPARAM)hFont, 0);

    m_gme.m_trackNum = CreateWindowExW(0, L"EDIT", L"ED_RED",
                                    WS_TABSTOP|WS_CHILD|WS_VISIBLE|ES_LEFT|WS_BORDER,
                                    80, 20, 240, 20,
                                    m_groupGME, (HMENU)(CMD_TrackID),
                                    m_hInstance, NULL);

    SendMessageW(m_gme.m_trackNum, WM_SETFONT, (WPARAM)hFont, 0);
    // with a spin control to its right side
    m_gme.m_trackNumUpDown = CreateWindowExW(0, UPDOWN_CLASS, L"SP_RED",
                                            WS_TABSTOP|WS_CHILD | WS_VISIBLE
                                            | UDS_ARROWKEYS | UDS_ALIGNRIGHT
                                            | UDS_SETBUDDYINT | WS_BORDER,
                                            80, 20, 240, 20,
                                            m_groupGME, (HMENU)(CMD_TrackIDspin), m_hInstance, NULL);
    SendMessageW(m_gme.m_trackNumUpDown, WM_SETFONT, (WPARAM)hFont, 0);

    // Set the buddy control.
    SendMessage(m_gme.m_trackNumUpDown, UDM_SETBUDDY, (LONG)m_gme.m_trackNum, 0L);
    // Set the range.
    SendMessage(m_gme.m_trackNumUpDown, UDM_SETRANGE, 0L, MAKELONG(32000, 0) );
    // Set the initial value
    SendMessage(m_gme.m_trackNumUpDown, UDM_SETPOS, 0L, MAKELONG((int)(0), 0));

    //SendMessage(m_gme.m_trackNumUpDown, UDS_WRAP, 0L, FALSE);




    m_groupMIDI = CreateWindowExW(0, L"BUTTON", L"MIDI Setup", WS_VISIBLE|WS_CHILD|BS_GROUPBOX|WS_GROUP,
                                left, top, 330, 50,
                                hWnd, (HMENU)GRP_MIDI, m_hInstance, NULL);
    SendMessageW(m_groupMIDI, WM_SETFONT, (WPARAM)hFont, 0);

    OldBtnProc = reinterpret_cast<WNDPROC>(static_cast<LONG_PTR>(
                 SetWindowLongPtr(m_groupMIDI, GWLP_WNDPROC,
                 reinterpret_cast<LONG_PTR>(MusPlayer_WinAPI::SubCtrlProc))) );
    SetWindowLongPtr(m_groupMIDI, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(OldBtnProc));

    top += 50;

    m_midi.m_labelDevice = CreateWindowExW(0, L"STATIC", L"MIDI Device:", WS_CHILD | WS_VISIBLE | SS_LEFT,
                                10, 20, 70, 15,
                                m_groupMIDI, NULL, m_hInstance, NULL);
    SendMessageW(m_midi.m_labelDevice, WM_SETFONT, (WPARAM)hFont, 0);

    const wchar_t* midiDevices[] = {
        L"ADL Midi (OPL Synth emulation)",
        L"Timidity (GUS-like wavetable MIDI Synth)",
        L"Native midi (Built-in MIDI of your OS)"
    };
    m_midi.m_midiDevice = CreateWindowExW(0, L"COMBOBOX", L"MidiDevice", WS_TABSTOP|WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_TABSTOP,
                                              80, 17, 240, 210, m_groupMIDI, (HMENU)CMD_MidiDevice, m_hInstance, NULL);
    SendMessageW(m_midi.m_midiDevice, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_midi.m_midiDevice, CB_ADDSTRING, 0, (LPARAM)midiDevices[0]);
    SendMessageW(m_midi.m_midiDevice, CB_ADDSTRING, 0, (LPARAM)midiDevices[1]);
    SendMessageW(m_midi.m_midiDevice, CB_ADDSTRING, 0, (LPARAM)midiDevices[2]);
    SendMessageW(m_midi.m_midiDevice, CB_SETCURSEL, 0, 0);

    m_groupADLMIDI = CreateWindowExW(0, L"BUTTON", L"ADLMIDI Extra Setup", WS_VISIBLE|WS_CHILD|BS_GROUPBOX|WS_GROUP,
                                left, top, 330, 125,
                                hWnd, (HMENU)GRP_ADLMIDI, m_hInstance, NULL);
    SendMessageW(m_groupADLMIDI, WM_SETFONT, (WPARAM)hFont, 0);
    //top += 50;

    OldBtnProc=reinterpret_cast<WNDPROC>(static_cast<LONG_PTR>(
                 SetWindowLongPtr(m_groupADLMIDI, GWLP_WNDPROC,
                 reinterpret_cast<LONG_PTR>(MusPlayer_WinAPI::SubCtrlProc))) );
    SetWindowLongPtr(m_groupADLMIDI, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(OldBtnProc));


    m_adlmidi.m_labelBank = CreateWindowExW(0, L"STATIC", L"ADL Midi bank ID:", WS_CHILD|WS_VISIBLE | SS_LEFT,
                                10, 20, 70, 15,
                                m_groupADLMIDI, NULL, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_labelBank, WM_SETFONT, (WPARAM)hFont, 0);

    m_adlmidi.m_bankID = CreateWindowExW(0, L"COMBOBOX", L"BankId", WS_TABSTOP|WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|CBS_DISABLENOSCROLL|WS_VSCROLL|CBS_NOINTEGRALHEIGHT|WS_TABSTOP,
                                              80, 17, 240, 210, m_groupADLMIDI, (HMENU)CMD_Bank, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_bankID, WM_SETFONT, (WPARAM)hFont, 0);
    int insCount            = MIX_ADLMIDI_getTotalBanks();
    const char*const* names = MIX_ADLMIDI_getBankNames();
    for(int i=0; i<insCount; i++)
    {
        SendMessageA(m_adlmidi.m_bankID, CB_ADDSTRING, 0, (LPARAM)names[i]);
    }
    SendMessageW(m_adlmidi.m_bankID, CB_SETCURSEL, 58, 0);


    m_adlmidi.m_tremolo = CreateWindowExW(0, L"BUTTON", L"Deep tremolo", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX,
                                          10, 40, 200, 15,
                                          m_groupADLMIDI, (HMENU)CMD_Tremolo, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_tremolo, WM_SETFONT, (WPARAM)hFont, 0);
    CheckDlgButton(m_groupADLMIDI, CMD_Tremolo, BST_CHECKED);

    m_adlmidi.m_vibrato = CreateWindowExW(0, L"BUTTON", L"Deep vibrato", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX,
                                          10, 60, 200, 15,
                                          m_groupADLMIDI, (HMENU)CMD_Vibrato, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_vibrato, WM_SETFONT, (WPARAM)hFont, 0);
    CheckDlgButton(m_groupADLMIDI, CMD_Vibrato, BST_CHECKED);

    m_adlmidi.m_scalableMod = CreateWindowExW(0, L"BUTTON", L"Scalable modulation", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX,
                                          10, 80, 200, 15,
                                          m_groupADLMIDI, (HMENU)CMD_ScalableMod, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_scalableMod, WM_SETFONT, (WPARAM)hFont, 0);
    CheckDlgButton(m_groupADLMIDI, CMD_ScalableMod, BST_UNCHECKED);

    m_adlmidi.m_adlibDrums = CreateWindowExW(0, L"BUTTON", L"AdLib drums mode", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX,
                                          10, 100, 200, 15,
                                          m_groupADLMIDI, (HMENU)CMD_AdLibDrums, m_hInstance, NULL);
    SendMessageW(m_adlmidi.m_adlibDrums, WM_SETFONT, (WPARAM)hFont, 0);
    CheckDlgButton(m_groupADLMIDI, CMD_AdLibDrums, BST_UNCHECKED);


    ShowWindow(m_groupGME, SW_HIDE);
    ShowWindow(m_groupMIDI, SW_HIDE);
    ShowWindow(m_groupADLMIDI, SW_HIDE);


    SendMessageW(hWnd, WM_SETFONT, (WPARAM)hFont, 0);

    SendMessageW(m_buttonOpen, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_buttonPlay, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_buttonStop, WM_SETFONT, (WPARAM)hFont, 0);

    SendMessageW(hText, WM_SETFONT, (WPARAM)hFontBold, 0);

    SendMessageW(m_labelTitle, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_labelArtist, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_labelAlboom, WM_SETFONT, (WPARAM)hFont, 0);
    SendMessageW(m_labelCopyright, WM_SETFONT, (WPARAM)hFont, 0);

    SetWindowTextW(hWnd, L"Simple SDL2 Mixer X Music player [WinAPI-based]");

    HMENU hSubMenu;
    m_contextMenu = CreatePopupMenu();
    AppendMenuW(m_contextMenu, MF_STRING, CMD_Open, L"Open");
    AppendMenuW(m_contextMenu, MF_STRING, CMD_Play, L"Play/Pause");
    AppendMenuW(m_contextMenu, MF_STRING, CMD_Stop, L"Stop");
    AppendMenuW(m_contextMenu, MF_SEPARATOR, 0, 0);
    AppendMenuW(m_contextMenu, MF_STRING, CMD_Reverb, L"Reverb");
    AppendMenuW(m_contextMenu, MF_STRING, CMD_AssocFiles, L"Associate files");
    EnableMenuItem(m_contextMenu, CMD_AssocFiles, MF_GRAYED);
    AppendMenuW(m_contextMenu, MF_SEPARATOR, 0, 0);

    hSubMenu = CreatePopupMenu();
    AppendMenuA(hSubMenu, MF_STRING, CMD_Version, "SDL Mixer X Music Player [WinAPI], v." _FILE_VERSION);
    EnableMenuItem(hSubMenu, CMD_Version, MF_GRAYED);
    AppendMenuW(hSubMenu, MF_STRING, CMD_ShowLicense, L"Licensed under GNU GPLv3 license");
    AppendMenuW(hSubMenu, MF_SEPARATOR, 0, 0);
    AppendMenuW(hSubMenu, MF_STRING, CMD_ShowSource, L"Get source code");

    AppendMenuW(m_contextMenu,  MF_STRING | MF_POPUP, (UINT)hSubMenu, L"About");

}
예제 #22
0
INT InitControls()
{
	Gdiplus::GdiplusStartupInput gdiplusStartupInput;
	Gdiplus::GdiplusStartup(&gdiplustoken, &gdiplusStartupInput, NULL);

	INITCOMMONCONTROLSEX	iccs;
	HFONT					font = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
	HINSTANCE				hinst = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);

	iccs.dwICC = ICC_STANDARD_CLASSES|ICC_BAR_CLASSES;
	iccs.dwSize = sizeof(INITCOMMONCONTROLSEX);
	
	InitCommonControlsEx(&iccs);

	// menu
	HMENU menu = CreateMenu();
	HMENU submenu1 = CreatePopupMenu();
	HMENU submenu2 = CreatePopupMenu();
	
	AppendMenuA(submenu1, MF_STRING, IDM_OPEN_ITEM, "&Open");
	AppendMenuA(submenu1, MF_STRING, IDM_SAVE_ITEM, "&Save");
	AppendMenuA(submenu1, MF_STRING, IDM_SAVEAS_ITEM, "Save &As");
	AppendMenuA(submenu1, MF_SEPARATOR, 0, 0);
	AppendMenuA(submenu1, MF_STRING, IDM_EXIT_ITEM, "&Exit");
	AppendMenuA(submenu2, MF_STRING, IDM_ABOUT_ITEM, "&About");

	AppendMenuA(menu, MF_STRING|MF_POPUP, (UINT)submenu1, "&File");
	AppendMenuA(menu, MF_STRING|MF_POPUP, (UINT)submenu2, "&Help");
	
	SetMenu(hwnd, menu);

	// button
	int starty = 30;

	button1 = CreateWindow(
		"BUTTON", "Click Me", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
		300, starty, 120, 40, hwnd, (HMENU)IDC_BUTTON1, hinst, 0);

	if( !button1 )
		return 0;

	SendMessage(button1, WM_SETFONT, (WPARAM)font, MAKELPARAM(TRUE, 0));

	// spinner
	spinner = CreateWindow(
		"STATIC", "", WS_VISIBLE|WS_CHILD|SS_OWNERDRAW,
		30, starty, 32, 32, hwnd, (HMENU)IDI_CIRCLE_ICON, hinst, 0);

	if( !spinner )
		return 0;

	animgif = new AnimatedGIF(spinner);
	animgif->SetResImage(MAKEINTRESOURCEW(IDI_CIRCLE_ICON));

	// trackbar with labels
	trackbar = CreateWindowEx(
		0, TRACKBAR_CLASS, "trackbar1", WS_CHILD|WS_VISIBLE|TBS_AUTOTICKS,
		80, starty + 2, 200, 30, hwnd, (HMENU)IDC_TRACKBAR, hinst, NULL);

	if( !trackbar )
		return 0;

	SendMessage(trackbar, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(1, 5));
	SendMessage(trackbar, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)2);
	SendMessage(trackbar, TBM_SETTICFREQ, 1, 0);
	SendMessage(trackbar, TBM_SETPAGESIZE, 0, (LPARAM)1);
	SendMessage(trackbar, TBM_SETLINESIZE, 0, (LPARAM)1);

	label1 = CreateWindow(
		"STATIC", "Slow", SS_LEFT|WS_VISIBLE|WS_CHILD,
		85, starty + 35, 50, 20, hwnd, 0, hinst, NULL);

	label2 = CreateWindow(
		"STATIC", "Fast", SS_RIGHT|WS_VISIBLE|WS_CHILD,
		220, starty + 35, 50, 20, hwnd, 0, hinst, NULL);

	SendMessage(label1, WM_SETFONT, (WPARAM)font, MAKELPARAM(TRUE, 0));
	SendMessage(label2, WM_SETFONT, (WPARAM)font, MAKELPARAM(TRUE, 0));

	// combobox
	RECT rc1 = { 6, 110, 6 + 160, 120 + 14 };
	RECT rc2 = { 270, 110, 270 + 160, 120 + 14 };

	combo1 = new CustomCombo();
	combo2 = new CustomCombo();

	combo1->Initialize(IDC_COMBO1, hwnd, rc1);
	combo2->Initialize(IDC_COMBO2, hwnd, rc2);

	combo1->AddString("Furunkulusz");
	combo1->AddString("@Kaktusz bónusz");
	combo1->AddString("@Trolibusz");
	combo1->AddString("Tökfilkusz");
	combo1->SetCurSel(0);

	combo2->AddString("@Tutihogyix");
	combo2->AddString("Csodaturmix");
	combo2->AddString("Hangjanix");
	combo2->AddString("@Obelix");
	combo2->AddString("Sokadikix");
	combo2->SetCurSel(2);
	
	// timer
	SetTimer(hwnd, IDC_TIMER, 80, 0);
	return 1;
}
예제 #23
0
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam,
                                   LPARAM lParam) {
  static SERVICE_TABLE_ENTRYA service_table[] = {
    {server_name, (LPSERVICE_MAIN_FUNCTIONA) ServiceMain},
    {NULL, NULL}
  };
  int service_installed;
  char buf[200], *service_argv[] = {__argv[0], NULL};
  POINT pt;
  HMENU hMenu;

  switch (msg) {
    case WM_CREATE:
      if (__argv[1] != NULL &&
          !strcmp(__argv[1], service_magic_argument)) {
        start_mongoose(1, service_argv);
        StartServiceCtrlDispatcherA(service_table);
        exit(EXIT_SUCCESS);
      } else {
        start_mongoose(__argc, __argv);
      }
      break;
    case WM_COMMAND:
      switch (LOWORD(wParam)) {
        case ID_QUIT:
          mg_stop(ctx);
          Shell_NotifyIconA(NIM_DELETE, &TrayIcon);
          PostQuitMessage(EXIT_SUCCESS);
          break;
        case ID_EDIT_CONFIG:
          edit_config_file(ctx);
          break;
        case ID_INSTALL_SERVICE:
        case ID_REMOVE_SERVICE:
          manage_service(LOWORD(wParam));
          break;
      }
      break;
    case WM_USER:
      switch (lParam) {
        case WM_RBUTTONUP:
        case WM_LBUTTONUP:
        case WM_LBUTTONDBLCLK:
          hMenu = CreatePopupMenu();
          AppendMenuA(hMenu, MF_STRING | MF_GRAYED, ID_SEPARATOR, server_name);
          AppendMenuA(hMenu, MF_SEPARATOR, ID_SEPARATOR, "");
          service_installed = manage_service(0);
          snprintf(buf, sizeof(buf), "NT service: %s installed",
                   service_installed ? "" : "not");
          AppendMenuA(hMenu, MF_STRING | MF_GRAYED, ID_SEPARATOR, buf);
          AppendMenuA(hMenu, MF_STRING | (service_installed ? MF_GRAYED : 0),
                     ID_INSTALL_SERVICE, "Install service");
          AppendMenuA(hMenu, MF_STRING | (!service_installed ? MF_GRAYED : 0),
                     ID_REMOVE_SERVICE, "Deinstall service");
          AppendMenuA(hMenu, MF_SEPARATOR, ID_SEPARATOR, "");
          AppendMenuA(hMenu, MF_STRING, ID_EDIT_CONFIG, "Edit config file");
          AppendMenuA(hMenu, MF_STRING, ID_QUIT, "Exit");
          GetCursorPos(&pt);
          SetForegroundWindow(hWnd);
          TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hWnd, NULL);
          PostMessage(hWnd, WM_NULL, 0, 0);
          DestroyMenu(hMenu);
          break;
      }
      break;
    case WM_CLOSE:
      mg_stop(ctx);
      Shell_NotifyIconA(NIM_DELETE, &TrayIcon);
      PostQuitMessage(EXIT_SUCCESS);
      return 0;  // We've just sent our own quit message, with proper hwnd.
  }

  return DefWindowProc(hWnd, msg, wParam, lParam);
}
예제 #24
0
void adjust_spell_menus() {
	if(menuHandle == NULL) return;
	short i, j, spell_pos = 0;
	HMENU spell_menu;
	short old_on_spell_menu[2][62];
	bool need_menu_change = false;

	if(overall_mode == MODE_STARTUP || current_pc == 6)
		return;

	for(i = 0; i < 2; i++)
		for(j = 0; j < 62; j++)
			old_on_spell_menu[i][j] = on_spell_menu[i][j];

	spell_menu = GetSubMenu(menuHandle, MAGE_MENU_POS);

	for(i = 0; i < 62; i++) {
		on_spell_menu[0][i] = -1;
	}
	for(i = 0; i < 62; i++)
		if(pc_can_cast_spell(current_pc, cSpell::fromNum(eSkill::MAGE_SPELLS, i))) {
			on_spell_menu[0][spell_pos] = i;
			spell_pos++;
		}
	for(i = 0; i < 62; i++)
		if(on_spell_menu[0][i] != old_on_spell_menu[0][i])
			need_menu_change = true;
	if(need_menu_change) {
		while(GetMenuItemCount(spell_menu) > 2) {
			RemoveMenu(spell_menu, 2, MF_BYPOSITION);
		}
		for(i = 0; i < 62; i++)
			if(on_spell_menu[0][i] >= 0) {
				eSpell spell = cSpell::fromNum(eSkill::MAGE_SPELLS, on_spell_menu[0][i]);
				std::ostringstream sout;
				sout << " L" << (*spell).level << " - " << (*spell).name() << ", C ";
				if((*spell).cost >= 0) sout << (*spell).cost; else sout << '?';
				AppendMenuA(spell_menu, MF_STRING | MF_ENABLED, 2000 + int(spell), sout.str().c_str());
			}
	}

	need_menu_change = false;
	spell_pos = 0;

	spell_menu = GetSubMenu(menuHandle, PRIEST_MENU_POS);

	for(i = 0; i < 62; i++) {
		on_spell_menu[1][i] = -1;
	}
	for(i = 0; i < 62; i++)
		if(pc_can_cast_spell(current_pc, cSpell::fromNum(eSkill::PRIEST_SPELLS, i))) {
			on_spell_menu[1][spell_pos] = i;
			spell_pos++;
		}
	for(i = 0; i < 62; i++)
		if(on_spell_menu[1][i] != old_on_spell_menu[1][i])
			need_menu_change = true;
	if(need_menu_change) {
		while(GetMenuItemCount(spell_menu) > 2) {
			RemoveMenu(spell_menu, 2, MF_BYPOSITION);
		}
		for(i = 0; i < 62; i++)
			if(on_spell_menu[1][i] >= 0) {
				eSpell spell = cSpell::fromNum(eSkill::MAGE_SPELLS, on_spell_menu[1][i]);
				std::ostringstream sout;
				sout << " L" << (*spell).level << " - " << (*spell).name() << ", C ";
				if((*spell).cost >= 0) sout << (*spell).cost; else sout << '?';
				AppendMenuA(spell_menu, MF_STRING | MF_ENABLED, 2000 + int(spell), sout.str().c_str());
			}
	}


}
예제 #25
0
BOOL CALLBACK KG_DlgKeyGenerate(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg)
    {
    case WM_INITDIALOG:
    {
        SetLevelList(hwndDlg);
        SetDlgItemTextA(hwndDlg, IDC_EDT_HWID, "0000-0000");
        bool en = false;
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER1), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER2), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER3), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER4), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_KEYSTRING), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_PVT), en);
        EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_Y), en);
        ShowWindow(GetDlgItem(hwndDlg, IDC_CHK_BABOON), 0);
        keygenerate_level = -1;
        SYSTEMTIME systime = {0};
        GetSystemTime(&systime);
        char temp[20] = "";
        sprintf(temp, "%d", MakeDate(systime.wYear, systime.wMonth, systime.wDay));
        SetDlgItemTextA(hwndDlg, IDC_EDT_DATE, temp);
        sprintf(temp, "%.4d-%.2d-%.2d", systime.wYear, systime.wMonth, systime.wDay);
        SetDlgItemTextA(hwndDlg, IDC_EDT_DATEYMD, temp);
        SendDlgItemMessageA(hwndDlg, IDC_EDT_KEYSTRING, EM_SETLIMITTEXT, 255, 0);
    }
    return TRUE;

    case WM_CONTEXTMENU:
    {
        if(GetDlgCtrlID((HWND)wParam) == IDC_EDT_SERIAL)
        {
            char serial[2048] = "";
            int len = GetDlgItemTextA(hwndDlg, IDC_EDT_SERIAL, serial, 2048);
            if(!len)
                return TRUE;
            HMENU myMenu = 0;
            myMenu = CreatePopupMenu();
            AppendMenu(myMenu, MF_STRING, 1, "Copy Serial");
            POINT cursorPos;
            GetCursorPos(&cursorPos);
            SetForegroundWindow(hwndDlg);
            UINT MenuItemClicked = TrackPopupMenu(myMenu, TPM_RETURNCMD | TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0);
            SendMessage(hwndDlg, WM_NULL, 0, 0);
            if(MenuItemClicked == 1)
            {
                CopyToClipboard(serial);
                MessageBeep(MB_ICONINFORMATION);
            }
        }
    }
    return TRUE;

    case WM_HELP:
    {
        char id[10] = "";
        sprintf(id, "%d", IDS_HELPKEYGEN);
        SetEnvironmentVariableA("HELPID", id);
        SetEnvironmentVariableA("HELPTITLE", "KeyGen Help");
        DialogBox(hInst, MAKEINTRESOURCE(DLG_HELP), hwndDlg, DlgHelp);
    }
    return TRUE;

    case WM_COMMAND:
    {
        switch(LOWORD(wParam))
        {
        case IDC_BTN_GENERATE:
        {
            NoFocus();
            char name[512] = "";
            char keystring[512] = "";
            char pvt[512] = "";
            char y[512] = "";
            char hwid[10] = "";
            char sym[10] = "";
            char templ[512] = "";
            unsigned int sy = 0, hw = 0;

            GetDlgItemTextA(hwndDlg, IDC_EDT_NAME, name, 512);
            GetDlgItemTextA(hwndDlg, IDC_EDT_KEYSTRING, keystring, 256);
            GetDlgItemTextA(hwndDlg, IDC_EDT_HWID, hwid, 10);
            GetDlgItemTextA(hwndDlg, IDC_EDT_SYM, sym, 10);
            FormatHex(hwid);
            FormatHex(sym);

            sscanf(hwid, "%X", &hw);
            sscanf(sym, "%X", &sy);
            sprintf(sym, "%.8X", sy);
            SetDlgItemTextA(hwndDlg, IDC_EDT_SYM, sym);

            GetDlgItemTextA(hwndDlg, IDC_EDT_PVT, pvt, 512);
            int len = GetDlgItemTextA(hwndDlg, IDC_EDT_Y, y, 512);
            int comma_count = 0;
            for(int i = 0; i < len; i++)
                if(y[i] == ',')
                    comma_count++;
            bool baboon = !!IsDlgButtonChecked(hwndDlg, IDC_CHK_BABOON);
            if(keygenerate_level == 29 and comma_count != 2 and !baboon)
            {
                AddLogMessage(GetDlgItem(hwndDlg, IDC_EDT_ADVLOG), "Invalid ECDSA Public format...\nUse: ", true);
                return TRUE;
            }
            if(((!*pvt) or (!*y)) and keygenerate_level != -1 and !baboon)
            {
                if(GetDlgItemTextA(hwndDlg, IDC_EDT_TEMPLATE, templ, 512))
                {
                    KG_GeneratePvtY(keygenerate_level, templ, pvt, y);
                    SetDlgItemTextA(hwndDlg, IDC_EDT_PVT, pvt);
                    SetDlgItemTextA(hwndDlg, IDC_EDT_Y, y);
                }
                else
                {
                    AddLogMessage(GetDlgItem(hwndDlg, IDC_EDT_ADVLOG), "You should enter the values for the key signing...", true);
                    return TRUE;
                }
            }

            int date = GetDlgItemInt(hwndDlg, IDC_EDT_DATE, 0, 0);
            int other0 = GetDlgItemInt(hwndDlg, IDC_EDT_OTHER0, 0, 0) & 65535;
            int other1 = GetDlgItemInt(hwndDlg, IDC_EDT_OTHER1, 0, 0) & 65535;
            int other2 = GetDlgItemInt(hwndDlg, IDC_EDT_OTHER2, 0, 0) & 65535;
            int other3 = GetDlgItemInt(hwndDlg, IDC_EDT_OTHER3, 0, 0) & 65535;
            int other4 = GetDlgItemInt(hwndDlg, IDC_EDT_OTHER4, 0, 0) & 65535;

            SetDlgItemInt(hwndDlg, IDC_EDT_DATE, date, 1);
            if(IsDlgButtonChecked(hwndDlg, IDC_CHK_MODKEY))
                date = 65344;
            SetDlgItemInt(hwndDlg, IDC_EDT_OTHER0, other0, 0);
            if(keygenerate_level != -1)
            {
                SetDlgItemInt(hwndDlg, IDC_EDT_OTHER1, other1, 0);
                SetDlgItemInt(hwndDlg, IDC_EDT_OTHER2, other2, 0);
                SetDlgItemInt(hwndDlg, IDC_EDT_OTHER3, other3, 0);
                SetDlgItemInt(hwndDlg, IDC_EDT_OTHER4, other4, 0);
            }
            SetDlgItemTextA(hwndDlg, IDC_EDT_SERIAL, CreateSignedKey(keygenerate_level, sy, keygenerate_sym_xorval, pvt, y, keystring, date, name, hw, other0, other1, other2, other3, other4, baboon, GetDlgItem(hwndDlg, IDC_EDT_ADVLOG)));
            SendMessageA(GetDlgItem(hwndDlg, IDC_EDT_ADVLOG), WM_VSCROLL, SB_BOTTOM, 0);
        }
        return TRUE;

        case IDC_BTN_MAKEDATE:
        {
            NoFocus();
            char date_text[20] = "";
            char new_date[20] = "";
            int len = GetDlgItemTextA(hwndDlg, IDC_EDT_DATEYMD, date_text, 20);
            for(int i = 0, j = 0; i < len; i++)
                if(date_text[i] != '-')
                    j += sprintf(new_date + j, "%c", date_text[i]);
            len = strlen(new_date);
            UINT dest_id;

            HMENU myMenu = 0;
            myMenu = CreatePopupMenu();

            if(len != 8)
                AppendMenuA(myMenu, MF_STRING | MF_GRAYED, 3, "Error!");
            else
            {
                AppendMenu(myMenu, MF_STRING, 1, "Date");
                AppendMenu(myMenu, MF_STRING, 2, "oth0");
            }
            POINT cursorPos;
            GetCursorPos(&cursorPos);
            SetForegroundWindow(hwndDlg);
            UINT MenuItemClicked = TrackPopupMenu(myMenu, TPM_RETURNCMD | TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0);
            SendMessage(hwndDlg, WM_NULL, 0, 0);
            switch(MenuItemClicked)
            {
            case 1:
                dest_id = IDC_EDT_DATE;
                break;
            case 2:
                dest_id = IDC_EDT_OTHER0;
                break;
            case 3:
                return TRUE;
                break;
            }

            char y[5] = "", m[3] = "", d[3] = "";
            int y_ = 0, m_ = 0, d_ = 0;
            strncpy(y, new_date, 4);
            strncpy(m, new_date + 4, 2);
            strncpy(d, new_date + 6, 2);
            sscanf(y, "%d", &y_);
            sscanf(m, "%d", &m_);
            sscanf(d, "%d", &d_);
            sprintf(date_text, "%d", MakeDate(y_, m_, d_));
            SetDlgItemTextA(hwndDlg, dest_id, date_text);
        }
        return TRUE;

        case IDC_CHK_BABOON:
        {
            NoFocus();
            bool baboon = true;
            if(IsDlgButtonChecked(hwndDlg, IDC_CHK_BABOON))
                baboon = false;
            EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_PVT), baboon);
            EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_Y), baboon);
        }
        return TRUE;

        case IDC_BTN_CALC:
        {
            NoFocus();
            char temp[1024] = "";
            char temp2[256] = "";
            UINT MenuItemClicked = 1;
            HMENU myMenu = 0;
            char clipboard[256] = "";
            char pvt[1024] = "";
            char y[1024] = "";

            if(!GetDlgItemTextA(hwndDlg, IDC_EDT_TEMPLATE, temp, 1024))
                return TRUE;

            KG_GeneratePvtY(keygenerate_level, temp, pvt, y);
            sprintf(temp, "%.8X", KG_GenerateSymmetric(keygenerate_level, temp));

            if(keygenerate_level >= 0)
            {
                myMenu = CreatePopupMenu();
                AppendMenuA(myMenu, MF_STRING, 4, "Sym Only");
                if(keygenerate_level == 29)
                    AppendMenu(myMenu, MF_STRING, 1, "Pvt, ECDSA, Sym");
                else
                    AppendMenu(myMenu, MF_STRING, 1, "Pvt, Y, Sym");
                if(keygenerate_level == 29)
                    AppendMenu(myMenu, MF_STRING, 2, "Pvt, ECDSA");
                else
                    AppendMenu(myMenu, MF_STRING, 2, "Pvt, Y");
                PasteFromClipboard(clipboard, 256);
                FormatHex(clipboard);
                int len = strlen(clipboard);
                if(len and len < 9)
                {
                    unsigned int clipboard_sym = 0;
                    sscanf(clipboard, "%X", &clipboard_sym);
                    if(keygenerate_level == 29)
                        sprintf(temp2, "Pvt, ECDSA, Sym: %.8X", clipboard_sym);
                    else
                        sprintf(temp2, "Pvt, Y, Sym: %.8X", clipboard_sym);
                    AppendMenu(myMenu, MF_STRING, 3, temp2);
                }
                POINT cursorPos;
                GetCursorPos(&cursorPos);
                SetForegroundWindow(hwndDlg);
                MenuItemClicked = TrackPopupMenu(myMenu, TPM_RETURNCMD | TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0);
                SendMessage(hwndDlg, WM_NULL, 0, 0);
            }
            switch(MenuItemClicked)
            {
            case 1:
            {
                SetDlgItemTextA(hwndDlg, IDC_EDT_Y, y);
                SetDlgItemTextA(hwndDlg, IDC_EDT_PVT, pvt);
                SetDlgItemTextA(hwndDlg, IDC_EDT_SYM, temp);
            }
            break;

            case 2:
            {
                SetDlgItemTextA(hwndDlg, IDC_EDT_Y, y);
                SetDlgItemTextA(hwndDlg, IDC_EDT_PVT, pvt);
            }
            break;

            case 3:
            {
                SetDlgItemTextA(hwndDlg, IDC_EDT_Y, y);
                SetDlgItemTextA(hwndDlg, IDC_EDT_PVT, pvt);
                SetDlgItemTextA(hwndDlg, IDC_EDT_SYM, clipboard);
            }
            break;

            case 4:
            {
                SetDlgItemTextA(hwndDlg, IDC_EDT_SYM, temp);
            }
            break;
            }
            if(keygenerate_level >= 0)
                DestroyMenu(myMenu);
        }
        return TRUE;

        case IDC_CHK_DIGITALRIVER: ///Digital River checkbox.
        {
            NoFocus();
            if(IsDlgButtonChecked(hwndDlg, LOWORD(wParam)))
            {
                CheckDlgButton(hwndDlg, IDC_CHK_ESELLERATE, 0);
                keygenerate_sym_xorval = 0x91827364; ///Official XOR value of DigitalRiver tagged keys...
            }
            else
                keygenerate_sym_xorval = 0;
        }
        return TRUE;

        case IDC_CHK_ESELLERATE: ///eSellerate checkbox.
        {
            NoFocus();
            if(IsDlgButtonChecked(hwndDlg, LOWORD(wParam)))
            {
                CheckDlgButton(hwndDlg, IDC_CHK_DIGITALRIVER, 0);
                keygenerate_sym_xorval = 0x19283746; ///Official XOR value of eSellerate tagged keys...
            }
            else
                keygenerate_sym_xorval = 0;
        }
        return TRUE;

        case IDC_CHK_MODKEY:
        {
            NoFocus();
        }
        return TRUE;

        case IDC_COMBO_LEVEL:
        {
            switch(HIWORD(wParam))
            {
            case CBN_SELCHANGE:
            {
                bool isNoSeperator = true;
                keygenerate_level = SendDlgItemMessageA(hwndDlg, LOWORD(wParam), CB_GETCURSEL, 0, 0);
                if(keygenerate_level == 1 or keygenerate_level == 6 or keygenerate_level == 16)
                    isNoSeperator = false;

                if(!keygenerate_level)
                    keygenerate_level--;
                else if(keygenerate_level > 1 and keygenerate_level < 6) //signed v2
                    keygenerate_level -= 2;
                else if(keygenerate_level > 6 and keygenerate_level < 16) //signed v3
                    keygenerate_level += 3;
                else if(keygenerate_level > 16) //short v3
                    keygenerate_level += 3;
                bool en = isNoSeperator;
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_NAME), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_HWID), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_TEMPLATE), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_CALC), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DIGITALRIVER), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ESELLERATE), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_SYM), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_DATEYMD), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_DATE), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_MAKEDATE), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER0), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_GENERATE), en);

                if(keygenerate_level == -1)
                    en = false;
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER1), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER2), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER3), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_OTHER4), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_PVT), en);
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_Y), en);
                en = false;
                if(keygenerate_level > 18 and isNoSeperator)
                    en = true;
                EnableWindow(GetDlgItem(hwndDlg, IDC_EDT_KEYSTRING), en);

                /*char temp[10]="";
                sprintf(temp, "%d", keygenerate_level);*/
                if(isNoSeperator)
                {
                    SetDlgItemTextA(hwndDlg, IDC_EDT_PVT, "");
                    SetDlgItemTextA(hwndDlg, IDC_EDT_Y, "");
                }
                bool baboon = false;
                if(keygenerate_level == 29)
                {
                    SetDlgItemTextA(hwndDlg, IDC_STC_YPUB, "ECDSA Public:");
                    baboon = true;
                }
                else
                {
                    SetDlgItemTextA(hwndDlg, IDC_STC_YPUB, "Y:");
                    CheckDlgButton(hwndDlg, IDC_CHK_BABOON, 0);
                }
                ShowWindow(GetDlgItem(hwndDlg, IDC_CHK_BABOON), baboon);
            }
            return TRUE;
            }
        }
        return TRUE;
        }
    }
    return TRUE;
    }
    return FALSE;
}
예제 #26
0
/**********************************************************************
 *						Functions
 *********************************************************************/
BOOL CALLBACK IH_DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg)
    {
    case WM_INITDIALOG:
    {
        g_HWND=hwndDlg;
        EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_INLINE), FALSE);
        EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_COPY), FALSE);
    }
    return TRUE;

    case WM_HELP:
    {
        char id[10]="";
        sprintf(id, "%d", IDS_HELPINLINE);
        SetEnvironmentVariableA("HELPID", id);
        SetEnvironmentVariableA("HELPTITLE", "Inline Help");
        DialogBox(hInst, MAKEINTRESOURCE(DLG_HELP), hwndDlg, DlgHelp);
    }
    return TRUE;

    case WM_BROWSE:
    {
        strcpy(g_szFileName, (const char*)wParam);
        //Retrieve the directory of the file.
        int i=strlen(g_szFileName)-1;
        int j=0;
        while(g_szFileName[i]!='\\')
        {
            i--;
            j++;
        }
        strncpy(g_szTargetDir, g_szFileName, strlen(g_szFileName)-j-1);

        //Retrieve stuff.
        EnableWindow(GetDlgItem(g_HWND, IDC_BTN_INLINE), FALSE);
        EnableWindow(GetDlgItem(g_HWND, IDC_BTN_COPY), FALSE);
        SendDlgItemMessageA(g_HWND, IDC_EDT_OEP, EM_SETREADONLY, 0, 0); //Enable change of OEP...
        DragAcceptFiles(g_HWND, FALSE);

        g_FileIsDll=IH_Debugger(g_szFileName, &g_TargetData, IH_DebugEnd_Callback, IH_ErrorMessageCallback);
    }
    return TRUE;

    case WM_DROPFILES:
    {
        //Get the dropped file name.
        DragQueryFileA((HDROP)wParam, 0, g_szFileName, 256);

        //Retrieve the directory of the file.
        int i=strlen(g_szFileName)-1;
        int j=0;
        while(g_szFileName[i]!='\\')
        {
            i--;
            j++;
        }
        strncpy(g_szTargetDir, g_szFileName, strlen(g_szFileName)-j-1);

        //Retrieve stuff.
        EnableWindow(GetDlgItem(g_HWND, IDC_BTN_INLINE), FALSE);
        EnableWindow(GetDlgItem(g_HWND, IDC_BTN_COPY), FALSE);
        SendDlgItemMessageA(g_HWND, IDC_EDT_OEP, EM_SETREADONLY, 0, 0); //Enable change of OEP...
        DragAcceptFiles(g_HWND, FALSE);

        g_FileIsDll=IH_Debugger(g_szFileName, &g_TargetData, IH_DebugEnd_Callback, IH_ErrorMessageCallback);
    }
    return TRUE;

    case WM_COMMAND:
    {
        switch(LOWORD(wParam))
        {
        case IDC_BTN_INLINE:
        {
            NoFocus();
            if(!(g_TargetData.EmptyEntry))
            {
                MessageBoxA(hwndDlg, "You need to specify the place to start the inline...", "N00B!", MB_ICONERROR);
                return TRUE;
            }
            char patch_filename[256]="";
            patch_filename[0]=0;
            OPENFILENAME ofstruct;
            memset(&ofstruct, 0, sizeof(ofstruct));
            ofstruct.lStructSize=sizeof(ofstruct);
            ofstruct.hwndOwner=hwndDlg;
            ofstruct.hInstance=hInst;
            if(!g_FileIsDll)
                ofstruct.lpstrFilter="Executable files (*.exe)\0*.exe\0\0";
            else
                ofstruct.lpstrFilter="Executable files (*.dll)\0*.dll\0\0";
            ofstruct.lpstrFile=patch_filename;
            ofstruct.nMaxFile=256;
            ofstruct.lpstrInitialDir=g_szTargetDir;
            ofstruct.lpstrTitle="Save file";
            if(!g_FileIsDll)
                ofstruct.lpstrDefExt="exe";
            else
                ofstruct.lpstrDefExt="dll";
            ofstruct.Flags=OFN_EXTENSIONDIFFERENT|OFN_HIDEREADONLY|OFN_NONETWORKBUTTON|OFN_OVERWRITEPROMPT;
            GetSaveFileName(&ofstruct);
            if(!patch_filename[0])
            {
                MessageBoxA(hwndDlg, "You must select a file...", "Warning", MB_ICONWARNING);
                return TRUE;
            }

            CopyFileA(g_szFileName, patch_filename, FALSE);
            SetPE32Data(patch_filename, 0, UE_OEP, g_TargetData.EmptyEntry-g_TargetData.ImageBase);
            long newflags=(long)GetPE32Data(patch_filename, g_TargetData.EntrySectionNumber, UE_SECTIONFLAGS);
            SetPE32Data(patch_filename, g_TargetData.EntrySectionNumber, UE_SECTIONFLAGS, (newflags|0x80000000));

            IH_GenerateAsmCode(g_codeText, g_TargetData);
            CopyToClipboard(g_codeText);
            MessageBoxA(hwndDlg, "1) Open the file you just saved with OllyDbg\n2) Open Multimate Assembler v1.5+\n3) Paste the code\n4) Modify the code to do something with the Security DLL\n5) Save the patched file with OllyDbg\n6) Enjoy!", "Instructions", MB_ICONINFORMATION);
        }
        return TRUE;

        case IDC_EDT_FREESPACE:
        {
            char free_temp[10]="";
            GetDlgItemTextA(hwndDlg, IDC_EDT_FREESPACE, free_temp, 10);
            sscanf(FormatTextHex(free_temp), "%X", &(g_TargetData.EmptyEntry));
        }
        return TRUE;

        case IDC_BTN_COPY:
        {
            NoFocus();
            if(g_codeText[0])
            {
                IH_GenerateAsmCode(g_codeText, g_TargetData);
                CopyToClipboard(g_codeText);
                MessageBoxA(hwndDlg, "Code copied to clipboard!", "Yay!", MB_ICONINFORMATION);
            }
            else
                MessageBoxA(hwndDlg, "There is no code to copy, please load a file first...", "Error!", MB_ICONERROR);
        }
        return TRUE;

        case IDC_BTN_PLUGINS:
        {
            NoFocus();
            PLUGFUNC PluginFunction;
            HINSTANCE PLUGIN_INST;
            char total_found_s[5]="";
            char plugin_name[100]="";
            char plugin_dll[100]="";
            char dll_to_load[256]="";
            char temp_str[5]="";
            int total_found=0;
            GetPrivateProfileStringA("Plugins", "total_found", "", total_found_s, 4, sg_szPluginIniFilePath);
            sscanf(total_found_s, "%d", &total_found);
            if(total_found)
            {
                HMENU myMenu=0;
                myMenu=CreatePopupMenu();
                for(int i=1; i!=(total_found+1); i++)
                {
                    sprintf(temp_str, "%d", i);
                    GetPrivateProfileStringA(temp_str, "plugin_name", "", plugin_name, 100, sg_szPluginIniFilePath);
                    AppendMenuA(myMenu, MF_STRING, i, plugin_name);
                }
                POINT cursorPos;
                GetCursorPos(&cursorPos);
                SetForegroundWindow(hwndDlg);
                UINT MenuItemClicked=TrackPopupMenu(myMenu, TPM_RETURNCMD|TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0);
                SendMessage(hwndDlg, WM_NULL, 0, 0);
                if(!MenuItemClicked)
                    return TRUE;

                sprintf(temp_str, "%d", (int)MenuItemClicked);
                GetPrivateProfileStringA(temp_str, "plugin_dll", "", plugin_dll, 100, sg_szPluginIniFilePath);
                sprintf(dll_to_load, "plugins\\%s", plugin_dll);

                PLUGIN_INST=LoadLibraryA(dll_to_load);
                if(!PLUGIN_INST)
                    MessageBoxA(hwndDlg, "There was an error loading the plugin", plugin_dll, MB_ICONERROR);
                else
                {
                    PluginFunction=(PLUGFUNC)GetProcAddress(PLUGIN_INST, "PluginFunction");
                    if(!PluginFunction)
                        MessageBoxA(hwndDlg, "The export \"PluginFunction\" could not be found, please contact the plugin supplier", plugin_dll, MB_ICONERROR);
                    else
                    {
                        if(!g_TargetData.ImageBase)
                            g_TargetData.ImageBase=0x400000;

                        ShowWindow(GetParent(hwndDlg), 0);
                        PluginFunction(PLUGIN_INST, hwndDlg, g_TargetData.SecurityAddrRegister, sg_szAKTDirectory, g_TargetData.ImageBase);
                        ShowWindow(GetParent(hwndDlg), 1);
                        FreeLibrary(PLUGIN_INST);
                        SetForegroundWindow(hwndDlg);

                    }
                }
            }
            else
            {
                HMENU myMenu=0;
                myMenu=CreatePopupMenu();
                AppendMenuA(myMenu, MF_STRING|MF_GRAYED, 1, "No plugins found :(");
                POINT cursorPos;
                GetCursorPos(&cursorPos);
                SetForegroundWindow(hwndDlg);
                TrackPopupMenu(myMenu, TPM_RETURNCMD|TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0);
            }
        }
        return TRUE;

        case IDC_EDT_OEP:
        {
            char temp_oep[10]="";
            GetDlgItemTextA(hwndDlg, IDC_EDT_OEP, temp_oep, 10);
            sscanf(temp_oep, "%X", &(g_TargetData.OEP));
        }
        return TRUE;
        }
    }
    return TRUE;
    }
    return FALSE;
}
예제 #27
0
static BOOL CALLBACK SkinEdit_ExtBkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    SKINDESCRIPTION *psd = (SKINDESCRIPTION *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

    if(psd) {
        ID_EXTBK_FIRST = psd->firstItem;
        ID_EXTBK_LAST = psd->lastItem;
        StatusItems = psd->StatusItems;
    }
    switch (msg) {
        case WM_INITDIALOG:
            psd = (SKINDESCRIPTION *)malloc(sizeof(SKINDESCRIPTION));
            ZeroMemory(psd, sizeof(SKINDESCRIPTION));
            CopyMemory(psd, (void *)lParam, sizeof(SKINDESCRIPTION));
            SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)psd);

            if(psd) {
                ID_EXTBK_FIRST = psd->firstItem;
                ID_EXTBK_LAST = psd->lastItem;
                StatusItems = psd->StatusItems;
            }

            TranslateDialogDefault(hwndDlg);
            FillItemList(hwndDlg);
            SendMessage(hwndDlg, WM_USER + 101, 0, 0);

            psd->hMenuItems = CreatePopupMenu();
            AppendMenu(psd->hMenuItems, MF_STRING | MF_DISABLED, (UINT_PTR)0, _T("Copy from"));
            AppendMenuA(psd->hMenuItems, MF_SEPARATOR, (UINT_PTR)0, NULL);

            {
				int i;
				
				for(i = ID_EXTBK_FIRST; i <= ID_EXTBK_LAST; i++) {
					int iOff = StatusItems[i - ID_EXTBK_FIRST].szName[0] == '{' ? 3 : 0;
					if(iOff)
						AppendMenuA(psd->hMenuItems, MF_SEPARATOR, (UINT_PTR)0, NULL);
					AppendMenuA(psd->hMenuItems, MF_STRING, (UINT_PTR)i, &StatusItems[i - ID_EXTBK_FIRST].szName[iOff]);
				}
			}
            return TRUE;
        case WM_USER + 101:
            {
                SendDlgItemMessage(hwndDlg, IDC_MRGN_LEFT_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
                SendDlgItemMessage(hwndDlg, IDC_MRGN_TOP_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
                SendDlgItemMessage(hwndDlg, IDC_MRGN_RIGHT_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
                SendDlgItemMessage(hwndDlg, IDC_MRGN_BOTTOM_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
                SendDlgItemMessage(hwndDlg, IDC_ALPHASPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
                SendDlgItemMessage(hwndDlg, IDC_ALPHASPIN2, UDM_SETRANGE, 0, MAKELONG(100, 0));

                return 0;
            }

        case WM_DRAWITEM:
            {
                DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *) lParam;
                int iItem = dis->itemData;
                TStatusItem *item = 0;

                SetBkMode(dis->hDC, TRANSPARENT);
                FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_WINDOW));

                if(iItem >= ID_EXTBK_FIRST && iItem <= ID_EXTBK_LAST)
                    item = &StatusItems[iItem - ID_EXTBK_FIRST];

                if (dis->itemState & ODS_SELECTED && iItem != ID_EXTBKSEPARATOR) {
                    FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
                    SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
                }
                else {
                    FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_WINDOW));
                    if(item && item->IGNORED)
                        SetTextColor(dis->hDC, RGB(255, 0, 0));
                    else if(item && item->dwFlags & S_ITEM_IMAGE_ONLY)
                    	SetTextColor(dis->hDC, RGB(0, 0, 255));
                    else
                        SetTextColor(dis->hDC, GetSysColor(COLOR_WINDOWTEXT));
                }
                if(iItem == ID_EXTBKSEPARATOR) {
                    HPEN    hPen, hPenOld;
                    POINT   pt;

                    hPen = CreatePen(PS_SOLID, 2, GetSysColor(COLOR_WINDOWTEXT));
                    hPenOld = (HPEN)SelectObject(dis->hDC, hPen);

                    MoveToEx(dis->hDC, dis->rcItem.left, (dis->rcItem.top + dis->rcItem.bottom) / 2, &pt);
                    LineTo(dis->hDC, dis->rcItem.right, (dis->rcItem.top + dis->rcItem.bottom) / 2);
                    SelectObject(dis->hDC, hPenOld);
                    DeleteObject((HGDIOBJ)hPen);
                }
                else if(dis->itemID >= 0 && item) {
                    char   *szName = item->szName[0] == '{' ? &item->szName[3] : item->szName;

                    TextOutA(dis->hDC, dis->rcItem.left, dis->rcItem.top, szName, lstrlenA(szName));
                }
                return TRUE;
            }

        case WM_CONTEXTMENU:
            {
                POINT pt;
                RECT  rc;
                HWND hwndList = GetDlgItem(hwndDlg, IDC_ITEMS);

                GetCursorPos(&pt);
                GetWindowRect(hwndList, &rc);
                if(PtInRect(&rc, pt)) {
                    int iSelection = (int)TrackPopupMenu(psd->hMenuItems, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);

                    if(iSelection >= ID_EXTBK_FIRST && iSelection <= ID_EXTBK_LAST) {
                        iSelection -= ID_EXTBK_FIRST;

                        for(int i = ID_EXTBK_FIRST; i <= ID_EXTBK_LAST; i++) {
                            if(SendMessage(hwndList, LB_GETSEL, i - ID_EXTBK_FIRST, 0) > 0) {
                                int iIndex = SendMessage(hwndList, LB_GETITEMDATA, i - ID_EXTBK_FIRST, 0);
                                iIndex -= ID_EXTBK_FIRST;

                                if(iIndex >= 0) {
                                    StatusItems[iIndex].ALPHA = StatusItems[iSelection].ALPHA;
                                    StatusItems[iIndex].COLOR = StatusItems[iSelection].COLOR;
                                    StatusItems[iIndex].COLOR2 = StatusItems[iSelection].COLOR2;
                                    StatusItems[iIndex].ALPHA2 = StatusItems[iSelection].ALPHA2;
                                    StatusItems[iIndex].CORNER = StatusItems[iSelection].CORNER;
                                    StatusItems[iIndex].GRADIENT = StatusItems[iSelection].GRADIENT;
                                    StatusItems[iIndex].IGNORED = StatusItems[iSelection].IGNORED;
                                    StatusItems[iIndex].imageItem = StatusItems[iSelection].imageItem;
                                    StatusItems[iIndex].MARGIN_BOTTOM = StatusItems[iSelection].MARGIN_BOTTOM;
                                    StatusItems[iIndex].MARGIN_LEFT = StatusItems[iSelection].MARGIN_LEFT;
                                    StatusItems[iIndex].MARGIN_RIGHT = StatusItems[iSelection].MARGIN_RIGHT;
                                    StatusItems[iIndex].MARGIN_TOP = StatusItems[iSelection].MARGIN_TOP;
                                    StatusItems[iIndex].TEXTCOLOR = StatusItems[iSelection].TEXTCOLOR;
                                    StatusItems[iIndex].dwFlags = StatusItems[iSelection].dwFlags;
                                }
                            }
                        }
                        OnListItemsChange(hwndDlg);
                    }
                }
                break;
            }
        case WM_COMMAND:
    // this will check if the user changed some actual statusitems values
    // if yes the flag bChanged will be set to TRUE
            SetChangedStatusItemFlag(wParam, hwndDlg);
            switch(LOWORD(wParam)) {
                case IDC_ITEMS:
                    if (HIWORD(wParam) != LBN_SELCHANGE)
                        return FALSE;
                    {
                        int iItem = SendDlgItemMessage(hwndDlg, IDC_ITEMS, LB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_ITEMS, LB_GETCURSEL, 0, 0), 0);
                        if(iItem == ID_EXTBKSEPARATOR)
                            return FALSE;
                    }
                    OnListItemsChange(hwndDlg);
					if(psd->pfnClcOptionsChanged)
						psd->pfnClcOptionsChanged();
                    break;
                case IDC_SKIP_UNDERLAY:
                case IDC_SKIP_IMAGE:
                case IDC_GRADIENT:
                case IDC_CORNER:
                case IDC_IGNORE:
                    ReActiveCombo(hwndDlg);
                    break;
            }
            if ((LOWORD(wParam) == IDC_ALPHA || LOWORD(wParam) == IDC_ALPHA2 || LOWORD(wParam) == IDC_MRGN_LEFT || LOWORD(wParam) == IDC_MRGN_BOTTOM || LOWORD(wParam) == IDC_MRGN_TOP || LOWORD(wParam) == IDC_MRGN_RIGHT) && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()))
                return 0;
            SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
            break;

        case WM_NOTIFY:
            switch (((LPNMHDR) lParam)->idFrom) {
                case 0:
                    switch (((LPNMHDR) lParam)->code) {
                        case PSN_APPLY:
                // save user made changes
                            SaveLatestChanges(hwndDlg);
                // save struct to DB
							if(psd->pfnSaveCompleteStruct)
								psd->pfnSaveCompleteStruct();

                            if(psd->pfnClcOptionsChanged)
								psd->pfnClcOptionsChanged();
							if(psd->hwndCLUI) {
								SendMessage(psd->hwndCLUI, WM_SIZE, 0, 0);
								PostMessage(psd->hwndCLUI, WM_USER+100, 0, 0);          // CLUIINTM_REDRAW
							}
                            break;
                    }
            }
            break;
        case WM_DESTROY:
            DestroyMenu(psd->hMenuItems);
            break;
        case WM_NCDESTROY:
            free(psd);
            SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)0);
            break;
    }
    return FALSE;
}