Exemplo n.º 1
0
BOOL MainCommandProc(HWND hWnd, WORD wCommand, WORD wNotify, HWND hControl)
{
	switch(wCommand){
		case CM_QUIT:
			DestroyWindow(hWnd);
			return 0;
			break;
		case CM_RESTART:
			cgame.restartGame();
			gamestatus=NOT_STARTED;
			RedrawWindow(hWnd, NULL, NULL, RDW_ERASE|RDW_INVALIDATE);
			return 0;
		case CM_CUSTOMGAME:
			if(GetFileName(cgame.mapfilename, sizeof(cgame.mapfilename), hWnd)==TRUE){
				cgame.restartGame();
				gamestatus=NOT_STARTED;
				RedrawWindow(hWnd, NULL, NULL, RDW_ERASE|RDW_INVALIDATE);
			}
			return 0;
		case CM_ABOUT:
			#ifndef WORKINGDIALOG
			MessageBox(hWnd, "WinCaslte: A Text Based Adventure\n\nVersion 4.01", "About", MB_OK|MB_ICONINFORMATION);
			#else
			DialogBox(NULL,MAKEINTRESOURCE(DIALOG_ABOUT), hWnd, DLGPROC(AboutBox));
			#endif
			return 0;
		case CM_GAMESTATISTICS:
			DialogBox(NULL,MAKEINTRESOURCE(DIALOG_2), hWnd, DLGPROC(StatisticsBox));
			return 0;
	}
	return TRUE;
}
Exemplo n.º 2
0
/* Connect Dialog */
BOOL CreateConnectDialog(HWND hwnd)
{
	if(currentDialogHandle)
		return FALSE;

	HWND connectDialog;
	RECT mainWinRect;
	RECT connWinRect;

	GetClientRect(hwnd, &mainWinRect);			

	connectDialog = CrateDialogFromTemplate(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG_CONNECT),
		hwnd, DLGPROC(ConnectDialogHandler));

	if(connectDialog == NULL)
		return FALSE;
	else
	{
		currentDialogHandle = connectDialog;
		GetClientRect(connectDialog, &connWinRect);

		int x = mainWinRect.right / 2 - connWinRect.right / 2;

		SetWindowPos(connectDialog, NULL, x, DIALOG_POS_Y, 
			0, 0, SWP_NOSIZE);
	}
}
Exemplo n.º 3
0
void ProgressDialog::show(Runnable& r, HWND hWndParent)
{
    // Store pointer to the Runnable instance
    runnable_ = &r;

    // Show dialog box
    if (DialogBoxParam(Globals::getHInstance(), LPCTSTR(IDD_PROGRESS), hWndParent, DLGPROC(staticDialogProc),
                       LPARAM(this)) < 1)
    {
        LOG_ERROR << "Failed showing progress dialog";
        MessageBoxA(hWndParent, "Error: Failed showing progress dialog", Globals::getClientName().cStr(), MB_ICONERROR);
    }
}
Exemplo n.º 4
0
LRESULT CALLBACK ParentMessageProcessingHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {	
	case WM_CREATE:
		{
			mainDialogHandle = hwnd;

			if(!TalkInitWinSock())
			{
				ShowError("An error ocured!\nThe program will now exit.", hwnd);
				DestroyWindow(hwnd);
			}

			if(!CreateConnectDialog(hwnd))
			{
				ShowError("The Application has encountered an internal error!", hwnd);
				DestroyWindow(hwnd);
			}
			else
			{
				talkPic = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_TALK));
				if(talkPic == NULL)
				{
					ShowError("The Application has encountered an internal error!", hwnd);
					DestroyWindow(hwnd);
				}
			}
		}
		break;

	case WM_SIZE:
			SizeConnectDialog(hwnd);
		break;

	case WM_SOCKET_MESSAGE:	//aici sunt mesajele winsock
		switch(WSAGETSELECTEVENT(lParam))
		{
		case FD_CONNECT: //server Connect
			break;
		case FD_READ:
			switch(connectionState)
			{
			case TRYING_TO_CONNECT:
				{
					vector<char *> *msgList;

					if((msgList = TalkReceiveMessage(wParam)) != NULL)
					{
						if(!msgList->empty())
						{
							if(TALK_MSG_BOOL_IS_MSG((*msgList)[0], TALK_MSG_TYPE_BEGIN_NICK_LIST))
							{
								size_t size = msgList->size();

								for(size_t i = 1; i < size; i++)
								{
									if(i == size - 1 && TALK_MSG_BOOL_IS_MSG((*msgList)[i], TALK_MSG_TYPE_END_NICK_LIST))
									{
										connectionState = CONNECTED;
										//TalkSendMessage(serverSocket, "Connected", 10);
										DistroyConnectDialog();
										SetClassLong(hwnd, GCL_HBRBACKGROUND, LONG(GetStockObject(WHITE_BRUSH)));
										InvalidateRect(hwnd, NULL, TRUE);
									}
									else
										addNick((*msgList)[i]);
								}

								if(connectionState != CONNECTED)
									connectionState = CONNECTION_ACCEPTED_GETTING_LIST;
							}

							else
							{
								ShowError("Nick name already in use!", hwnd);
								connectionState = UNCONNECTED;
							}
						}
					}
					else
					{
						ShowError("TRYING_TO_CONNECT error!", hwnd);
						connectionState = UNCONNECTED;
					}
				}
				break;
			case CONNECTION_ACCEPTED_GETTING_LIST:
				{
					vector<char *> *msgList;

					if((msgList = TalkReceiveMessage(wParam)) != NULL)
					{
						size_t size = msgList->size();

						for(size_t i = 0; i < size; i++)
							if(i == size - 1 && TALK_MSG_BOOL_IS_MSG((*msgList)[i], TALK_MSG_TYPE_END_NICK_LIST))
							{
								connectionState = CONNECTED;
								//TalkSendMessage(serverSocket, "Connected", 10);
								DistroyConnectDialog();
								SetClassLong(hwnd, GCL_HBRBACKGROUND, LONG(GetStockObject(WHITE_BRUSH)));
								InvalidateRect(hwnd, NULL, TRUE);
							}
							else
								addNick((*msgList)[i]);
					}
					else
					{
						ShowError("CONNECTION_ACCEPTED_GETTING_LIST error!", hwnd);
						connectionState = UNCONNECTED;
					}
				}
				break;
			case CONNECTED:
				{
					vector<char *> *msgList;

					if((msgList = TalkReceiveMessage(wParam)) != NULL)
					{
						size_t size = msgList->size();

						for(size_t i = 0; i < size; i++)
						{
							switch(TALK_MSG_VAL_MSG_TYPE((*msgList)[i]))
							{
							case TALK_MSG_TYPE_NORMAL_MSG:
								{
									char *src;
									char *msg;
									map<char *, HWND, ltstr>::iterator itr;

									TALK_GET_MSG_NORMAL_MSG_DEST_MSG((*msgList)[i], src, msg);

									itr = nickList.find(src);

									if(itr->second == NULL)
									{
										itr->second = CrateDialogFromTemplate(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG_CHAT),
											NULL, DLGPROC(InstantTalkProcessingHandler));
										
										if(itr->second == NULL)
										{
											ShowError("The Application has encountered an internal error!", hwnd);
											break;
										}
										else
										{
											char instDlgCapt[256];
											strcpy(instDlgCapt, itr->first);
											strcat(instDlgCapt, " - Instant Talk");

											SetWindowText(itr->second, instDlgCapt);

											openConversationList[itr->second] = itr->first;
										}
									}

									SendMessage(itr->second, GOT_MSG, (WPARAM)(msg), 0);
								}
								break;
							case TALK_MSG_TYPE_CLIENT_CONN_NOTIF:
								addNick(TALK_GET_MSG_CLIENT_CONN_NOTIF((*msgList)[i]));
								InvalidateRect(hwnd, NULL, TRUE);
								break;
							case TALK_MSG_TYPE_CLIENT_DISC_NOTIF:
								removeNick(TALK_GET_MSG_CLIENT_CONN_NOTIF((*msgList)[i]));
								InvalidateRect(hwnd, NULL, TRUE);
								break;
							}
						}
					}
				}
				break;
			}
			break;
		case FD_CLOSE:
			{
				if(serverSocket == wParam)
				{
					resetNickName();
					TalkShutDownConnection(wParam);

					if(connectionState == CONNECTED)
					{
						connectionState = UNCONNECTED;
						if(!CreateConnectDialog(hwnd))
						{
							ShowError("The Application has encountered an internal error!", hwnd);
							DestroyWindow(hwnd);
						}

						SetClassLong(hwnd, GCL_HBRBACKGROUND, LONG(COLOR_3DSHADOW));
						InvalidateRect(hwnd, NULL, TRUE);

						ShowError("Connection with server lost!", hwnd);
					}
				}
			}
			break;
		}
		break;

	case WM_SYSKEYDOWN:
	case WM_KEYDOWN:
		if(connectionState == CONNECTED)
		{
			switch (wParam) 
			{
			case VK_UP:
				if(selectedEntry > 0)
				{
					selectedEntry --;
					InvalidateRect(hwnd, NULL, TRUE);
				}
				break;
			case VK_DOWN:
				if(selectedEntry < nickList.size() - 1)
				{
					selectedEntry ++;
					InvalidateRect(hwnd, NULL, TRUE);
				}
				break;
			case VK_RETURN:
				if(connectionState == CONNECTED)
				{
					map<char *, HWND, ltstr>::iterator itr = nickList.begin();
					for(unsigned int i = 0; i < selectedEntry; i++, itr++);
					
					if(itr->second == NULL)
					{
						itr->second = CrateDialogFromTemplate(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG_CHAT),
							NULL, DLGPROC(InstantTalkProcessingHandler));
						
						if(itr->second == NULL)
						{
							ShowError("The Application has encountered an internal error!", hwnd);
						}
						else
						{
							char instDlgCapt[256];
							strcpy(instDlgCapt, itr->first);
							strcat(instDlgCapt, " - Instant Talk");

							SetWindowText(itr->second, instDlgCapt);
						}
					}
					else
						SetFocus(itr->second);
				}
				break;
			}
		}
		break;

	case WM_LBUTTONDOWN:
			if(connectionState == CONNECTED)
			{
				BITMAP bitmap;
				GetObject(talkPic, sizeof(bitmap), &bitmap);

				int i = (HIWORD(lParam) - 5) / (bitmap.bmHeight + 5);
				if(i < nickList.size())
				{
					selectedEntry = i;
					InvalidateRect(hwnd, NULL, TRUE);
				}
			}
		break;
	
	case WM_LBUTTONDBLCLK:
		if(connectionState == CONNECTED)
		{
			map<char *, HWND, ltstr>::iterator itr = nickList.begin();
			for(unsigned int i = 0; i < selectedEntry; i++, itr++);
			
			if(itr->second == NULL)
			{
				itr->second = CrateDialogFromTemplate(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG_CHAT),
					NULL, DLGPROC(InstantTalkProcessingHandler));
				
				if(itr->second == NULL)
				{
					ShowError("The Application has encountered an internal error!", hwnd);
				}
				else
				{
					char instDlgCapt[256];
					strcpy(instDlgCapt, itr->first);
					strcat(instDlgCapt, " - Instant Talk");

					SetWindowText(itr->second, instDlgCapt);

					openConversationList[itr->second] = itr->first;
				}
			}
			else
				SetFocus(itr->second);
		}
		break;

	case WM_PAINT://aici e paintu
		{
			PAINTSTRUCT paintStr;

			HDC hdc = BeginPaint(hwnd, &paintStr);

			if(connectionState == CONNECTED)
			{
				BITMAP bitmap;

				HDC hdcMem = CreateCompatibleDC(hdc);
				HBITMAP oldBitmap = (HBITMAP)SelectObject(hdcMem, talkPic);

				GetObject(talkPic, sizeof(bitmap), &bitmap);
				
				//size_t listSize = nickList.size();
				map<char *, HWND, ltstr>::iterator itr, itrend;
				itrend = nickList.end();
				unsigned int i = 0;
				for(itr = nickList.begin(); itr != itrend; itr++, i++)
				{
					BitBlt(hdc, 15, 5 + (bitmap.bmHeight + 5) * i, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY);
					if(i == selectedEntry)
					{
						SetTextColor(hdc, RGB(255, 255, 255));
						SetBkColor(hdc, RGB(100, 20, 180));
					}
					TextOut(hdc, 20 + bitmap.bmWidth, 5 + (bitmap.bmHeight + 5) * i, (*itr).first, strlen((*itr).first));
					if(i == selectedEntry)
					{
						SetBkColor(hdc, RGB(255, 255, 255));
						SetTextColor(hdc, RGB(0, 0, 0));
					}
				}

				SelectObject(hdcMem, oldBitmap);
				DeleteDC(hdcMem);
			}

			EndPaint(hwnd, &paintStr);
		}
		break;
    case WM_CLOSE:
        DestroyWindow(hwnd);
    break;
    case WM_DESTROY:
		{
			//daca se inchide aplicatia inchide toate conversatiile si elibereaza memoria 
			//ocupata de lista de nickuri
			resetNickName();
			clearNickList();

			if(talkPic != NULL)
			{
				DeleteObject(talkPic);
			}

			TalkShutDownWinSock();

			PostQuitMessage(0);
		}
    break;
    default:
        return DefWindowProc(hwnd, msg, wParam, lParam);
    }

    return FALSE;
}
Exemplo n.º 5
0
//新的计算器过程函数
LRESULT CALLBACK WindowProc(  HWND hwnd,      // handle to window
                                UINT uMsg,      // message identifier
                                WPARAM wParam,  // first message parameter
                                LPARAM lParam   // second message parameter
                            )
{
#ifdef HOOK_HOME
    EnterCriticalSection(&g_cs);
#endif

    //0x84
    if (uMsg == WM_COMMAND)
    {
         WORD wNotifyCode = HIWORD(wParam); 
         WORD wID = LOWORD(wParam); 
         HWND hwndCtl = (HWND) lParam;
         if (hwndCtl != NULL)
         {
            if (VK_FOR_8 == wID 
                && BN_CLICKED == wNotifyCode)
            {
                ::MessageBox(NULL, "8 Clicked", "Inject", MB_OK);
            }
         }//控件
         else if (0 == wNotifyCode)
         {
            if (MYMSG_FEATURE == wID)
            {
                MessageBox(NULL, "FEATURE", NULL, MB_OK);
                DialogBox(g_hModule, 
                            MAKEINTRESOURCE(IDD_DIALOG1),
                            g_hCalc,
                            DLGPROC(DlgProc)
                            );
            }
            else if (MYMSG_ABOUT == wID)
            {
                MessageBox(NULL, "ABOUT", NULL, MB_OK);
            }
        }//menu
    }
    else if (WM_KEYDOWN == uMsg)
    {
        //::MessageBox(NULL, "WM_KEYUP", NULL, MB_OK); 

        //#define VK_HOME           0x24
        if (VK_HOME == wParam)
        {
            ::MessageBox(NULL, "Home", NULL, MB_OK);

            ProcessWalk();
        }
        else if ('8' == wParam)
        {
            UnloadDLL();
        }
    }    

#ifdef HOOK_HOME
    //查找hWnd所对应的消息处理函数
    for (int i = 0; i < g_nCount; i++)
    {
        if (hwnd == g_hWnd[i])
        {
            break;
        }
    }

    LRESULT lRet = g_OldProc[i](hwnd, uMsg, wParam, lParam);

    LeaveCriticalSection(&g_cs);
    return lRet;
#else
    return g_pfnOld(hwnd, uMsg, wParam, lParam);
#endif
}
Exemplo n.º 6
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DLGPROC(DialogProc));
}
Exemplo n.º 7
0
bool DlgController::OnCommand (int ctrlid, int code)
{
	int	i =	0;
	switch (ctrlid)
	{
	case IDC_BUTTON_ABOUT:
		::DialogBox	(_hInst, MAKEINTRESOURCE (DLG_ABOUT), _hWnd, DLGPROC (AboutDlgProc));
		return true;
	case IDC_BUTTON_START:
		if (_isStopped)
		{
			_isStopped = !_painter.Start();
			if (_isStopped)
			{
				_buttonStart.SetText ("Start");
			}
			else
			{
				_buttonStart.SetText ("Stop");
			}
		}
		else
		{
			Stop ();
			_buttonStart.SetText ("Start");
			_isStopped = true;
		}
		return true;
	case IDC_RADIO_8_BITS:
		if (_radio8.IsClicked (code))
		{
			_bitsPerSample = 8;
			ReInit ();
		}
		return true;
	case IDC_RADIO_16_BITS:
		if (_radio16.IsClicked (code))
		{
			_bitsPerSample = 16;
			ReInit ();
		}
		return true;
	case IDC_RADIO_MIKE:
		if (_mike.IsClicked (code))
		{
			_painter.SetSource (SRC_MIKE);
			ReInit ();
			return true;
		}
		break;
	case IDC_RADIO_FILE:
		if (_wave.IsClicked (code))
		{
			SelectFile (SRC_WAVE);
			return true;
		}
		break;
	case IDC_RADIO_IMAGE:
		if (_image.IsClicked (code))
		{
			SelectFile (SRC_IMAGE);
			return true;
		}
		break;
	case IDC_EDIT_FILE:
		if (_editFile.IsChanged (code))
			::PostMessage (_hWnd, WM_COMMAND, MAKEWPARAM (IDC_BUTTON_FILE, 0), 0);
		break;
	case IDC_BUTTON_FILE:
		{
			std::string name = _editFile.GetString ();
			SourceType type = ValidateFile (name, SRC_ANY);
			if (type == SRC_WAVE)
			{
				_mike.UnCheck ();
				_image.UnCheck ();
				_wave.Check ();
				_painter.SetSource (SRC_WAVE, name.c_str ());
			}
			else if (type == SRC_IMAGE)
			{
				_mike.UnCheck ();
				_wave.UnCheck ();
				_image.Check ();
				_painter.SetSource (SRC_IMAGE, name.c_str ());
			}
			else
			{
				_wave.UnCheck ();
				_image.UnCheck ();
				_mike.Check ();
				_painter.SetSource (SRC_MIKE);
			}
			InitScrollPositions	();
			ReInit ();
		}
		return true;
	case IDC_COMBO_SAMPLING:
		if (_comboFreq.IsChanged (code))
		{
			_samplesPerSecond =	_comboFreq.GetValue	();
			InitScrollPositions	();
			ReInit ();
			return true;
		}	 
		break;
	case IDC_COMBO_POINTS:
		if (_comboPoints.IsChanged(code))
		{
			_fftPoints = _comboPoints.GetValue ();
			InitScrollPositions	();
			ReInit ();
			return true;
		}
	}
	return false;
}
Exemplo n.º 8
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND  - process the application menu
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case 1998:
	{
		SetWindowText(hWnd, L"Catch");
		if (!hNew)
		{
			hNew = CreateWindow(TEXT("BUTTON"), TEXT("NEW"), WS_CHILD | WS_VISIBLE, x1, y1, x2, y2, ::hWnd, (HMENU)995, nullptr, nullptr);
		}
		else 
		{
			DestroyWindow(hNew);
			hNew = CreateWindow(TEXT("BUTTON"), TEXT("NEW"), WS_CHILD | WS_VISIBLE, x1, y1, x2, y2, ::hWnd, (HMENU)995, nullptr, nullptr);
		}
		//InvalidateRect(hNew, NULL, FALSE);
		//UpdateWindow(hWnd);
		break;
	}
	case WM_COMMAND:
	{
		int wmId = LOWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case 999:
		{
			if (!hDlg)
			{
				hDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, DLGPROC(DlgProc));
			}
			else
			{
				DestroyWindow(hDlg);
				hDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, DLGPROC(DlgProc));
			}
			SetWindowText(hWnd, L"Wait enter...");
			ShowWindow(hDlg, 1);
		}
		break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
	}
	break;
	case WM_PAINT:
	{
		PAINTSTRUCT ps;
		HDC hdc = BeginPaint(hWnd, &ps);
		// TODO: Add any drawing code that uses hdc here...
		EndPaint(hWnd, &ps);
	}
	break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}