BOOL CContainer::OnColumnDlgLvnItemChanging(HWND hDlg,LPARAM lParam)
{
    NMLISTVIEW *nmlv;
    HWND hListView;

    nmlv = (NMLISTVIEW *)lParam;

    hListView = GetDlgItem(hDlg,IDC_COLUMNS_LISTVIEW);

    if((nmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK(2))
    {
        /* The item was checked. */
        EnableWindow(GetDlgItem(hDlg,IDC_COLUMNS_ENABLE),FALSE);
        EnableWindow(GetDlgItem(hDlg,IDC_COLUMNS_DISABLE),TRUE);

        g_nChecked++;
    }
    else if((nmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK(1))
    {
        /* The item was unchecked. */

        if(g_nChecked != 1)
        {
            EnableWindow(GetDlgItem(hDlg,IDC_COLUMNS_DISABLE),FALSE);
            EnableWindow(GetDlgItem(hDlg,IDC_COLUMNS_ENABLE),TRUE);

            g_nChecked--;
        }
        else
        {
            /* Can't just return. Need to set the DWL_MSGRESULT
            value to the return value first. */
            SetWindowLongPtr(hDlg,DWLP_MSGRESULT,TRUE);
            return TRUE;
        }
    }
    else if(nmlv->uNewState & LVIS_SELECTED)
    {
        LVITEM lvItem;
        TCHAR szColumnDescription[128];
        int iDescriptionStringIndex;

        lvItem.mask		= LVIF_PARAM;
        lvItem.iItem	= nmlv->iItem;
        lvItem.iSubItem	= 0;

        ListView_GetItem(hListView,&lvItem);

        iDescriptionStringIndex = LookupColumnDescriptionStringIndex((int)lvItem.lParam);

        LoadString(g_hLanguageModule,iDescriptionStringIndex,szColumnDescription,
                   SIZEOF_ARRAY(szColumnDescription));
        SetDlgItemText(hDlg,IDC_COLUMNS_DESCRIPTION,szColumnDescription);

        if(ListView_GetCheckState(hListView,nmlv->iItem))
        {
            EnableWindow(GetDlgItem(hDlg,IDC_COLUMNS_ENABLE),FALSE);
            EnableWindow(GetDlgItem(hDlg,IDC_COLUMNS_DISABLE),TRUE);
        }
        else
        {
            EnableWindow(GetDlgItem(hDlg,IDC_COLUMNS_DISABLE),FALSE);
            EnableWindow(GetDlgItem(hDlg,IDC_COLUMNS_ENABLE),TRUE);
        }
    }

    return FALSE;
}
Example #2
0
static INT_PTR CALLBACK DlgProcSetNickname(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		SendDlgItemMessage(hwndDlg, IDC_NICKNAME, EM_LIMITTEXT, MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE - 1, 0);
		return TRUE;

	case WMU_SETDATA:
	{
		int proto_num = (int)wParam;

		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, proto_num);

		if (proto_num == -1) {
			SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_MIRANDA));

			// All protos have the same nick?
			if (protocols->GetSize() > 0) {
				TCHAR *nick = protocols->Get(0)->nickname;

				bool foundDefNick = true;
				for (int i = 1; foundDefNick && i < protocols->GetSize(); i++) {
					if (mir_tstrcmpi(protocols->Get(i)->nickname, nick) != 0) {
						foundDefNick = false;
						break;
					}
				}

				if (foundDefNick)
					if (mir_tstrcmpi(protocols->default_nick, nick) != 0)
						mir_tstrcpy(protocols->default_nick, nick);
			}

			SetDlgItemText(hwndDlg, IDC_NICKNAME, protocols->default_nick);
			SendDlgItemMessage(hwndDlg, IDC_NICKNAME, EM_LIMITTEXT, MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE, 0);
		}
		else {
			Protocol *proto = protocols->Get(proto_num);

			TCHAR tmp[128];
			mir_sntprintf(tmp, _countof(tmp), TranslateT("Set my nickname for %s"), proto->description);

			SetWindowText(hwndDlg, tmp);

			HICON hIcon = (HICON)CallProtoService(proto->name, PS_LOADICON, PLI_PROTOCOL, 0);
			if (hIcon != NULL) {
				SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
				DestroyIcon(hIcon);
			}

			SetDlgItemText(hwndDlg, IDC_NICKNAME, proto->nickname);
			SendDlgItemMessage(hwndDlg, IDC_NICKNAME, EM_LIMITTEXT,
				min(MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE, proto->GetNickMaxLength()), 0);
		}

		return TRUE;
	}

	case WM_COMMAND:
		switch (wParam) {
		case IDOK:
		{
			TCHAR tmp[MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE];
			GetDlgItemText(hwndDlg, IDC_NICKNAME, tmp, _countof(tmp));

			LONG_PTR proto_num = GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
			if (proto_num == -1)
				protocols->SetNicks(tmp);
			else
				protocols->Get(proto_num)->SetNick(tmp);

			DestroyWindow(hwndDlg);
			break;
		}
		case IDCANCEL:
			DestroyWindow(hwndDlg);
			break;
		}
		break;

	case WM_CLOSE:
		DestroyWindow(hwndDlg);
		break;

	case WM_DESTROY:
		InterlockedExchange(&nickname_dialog_open, 0);
		break;
	}

	return FALSE;
}
Example #3
0
INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	RECT r;
	RECT r2;
	int dx1, dy1, dx2, dy2;

	switch (msg) {

	case WM_INITDIALOG:
	{
						  // remove the 30000 character limit from the console control
						  SendMessage(GetDlgItem(hDlg, IDC_LUACONSOLE), EM_LIMITTEXT, 0, 0);


						  //GetWindowRect(GetParent(hDlg), &r);
						  GetWindowRect(gApp.hWnd, &r);
						  dx1 = (r.right - r.left) / 2;
						  dy1 = (r.bottom - r.top) / 2;

						  GetWindowRect(hDlg, &r2);
						  dx2 = (r2.right - r2.left) / 2;
						  dy2 = (r2.bottom - r2.top) / 2;

						  int windowIndex = 0;//std::find(LuaScriptHWnds.begin(), LuaScriptHWnds.end(), hDlg) - LuaScriptHWnds.begin();
						  int staggerOffset = windowIndex * 24;
						  r.left += staggerOffset;
						  r.right += staggerOffset;
						  r.top += staggerOffset;
						  r.bottom += staggerOffset;

						  // push it away from the main window if we can
						  const int width = (r.right - r.left);
						  const int width2 = (r2.right - r2.left);
						  if (r.left + width2 + width < GetSystemMetrics(SM_CXSCREEN))
						  {
							  r.right += width;
							  r.left += width;
						  }
						  else if ((int)r.left - (int)width2 > 0)
						  {
							  r.right -= width2;
							  r.left -= width2;
						  }

						  SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);


						  RECT r3;
						  GetClientRect(hDlg, &r3);
						  windowInfo.width = r3.right - r3.left;
						  windowInfo.height = r3.bottom - r3.top;
						  for (int i = 0; i < numControlLayoutInfos; i++) {
							  ControlLayoutState& layoutState = windowInfo.layoutState[i];
							  layoutState.valid = false;
						  }

						  DragAcceptFiles(hDlg, true);
						  SetDlgItemText(hDlg, IDC_EDIT_LUAPATH, PCSX2GetLuaScriptName());

						  SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &LuaConsoleLogFont, 0); // reset with an acceptable font

						  LuaConsoleHWnd = GetDlgItem(hDlg, IDC_LUACONSOLE);
						  consoleputstring.clear();
						  consoleputstring.reserve(250000);
						  return true;
	}       break;

	case WM_SIZE:
	{
					// resize or move controls in the window as necessary when the window is resized

					//LuaPerWindowInfo& windowInfo = LuaWindowInfo[hDlg];
					int prevDlgWidth = windowInfo.width;
					int prevDlgHeight = windowInfo.height;

					int dlgWidth = LOWORD(lParam);
					int dlgHeight = HIWORD(lParam);

					int deltaWidth = dlgWidth - prevDlgWidth;
					int deltaHeight = dlgHeight - prevDlgHeight;

					for (int i = 0; i < numControlLayoutInfos; i++)
					{
						ControlLayoutInfo layoutInfo = controlLayoutInfos[i];
						ControlLayoutState& layoutState = windowInfo.layoutState[i];

						HWND hCtrl = GetDlgItem(hDlg, layoutInfo.controlID);

						int x, y, width, height;
						if (layoutState.valid)
						{
							x = layoutState.x;
							y = layoutState.y;
							width = layoutState.width;
							height = layoutState.height;
						}
						else
						{
							RECT r;
							GetWindowRect(hCtrl, &r);
							POINT p = { r.left, r.top };
							ScreenToClient(hDlg, &p);
							x = p.x;
							y = p.y;
							width = r.right - r.left;
							height = r.bottom - r.top;
						}

						switch (layoutInfo.horizontalLayout)
						{
						case ControlLayoutInfo::RESIZE_END: width += deltaWidth; break;
						case ControlLayoutInfo::MOVE_START: x += deltaWidth; break;
						default: break;
						}
						switch (layoutInfo.verticalLayout)
						{
						case ControlLayoutInfo::RESIZE_END: height += deltaHeight; break;
						case ControlLayoutInfo::MOVE_START: y += deltaHeight; break;
						default: break;
						}

						SetWindowPos(hCtrl, 0, x, y, width, height, 0);

						layoutState.x = x;
						layoutState.y = y;
						layoutState.width = width;
						layoutState.height = height;
						layoutState.valid = true;
					}

					windowInfo.width = dlgWidth;
					windowInfo.height = dlgHeight;

					RedrawWindow(hDlg, NULL, NULL, RDW_INVALIDATE);
	}       break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDOK:
		case IDCANCEL: {
						   EndDialog(hDlg, true); // goto case WM_CLOSE;
		}       break;

		case IDC_BUTTON_LUARUN:
		{
								  if (!g_ReturnToGui)
								  {
									  consoleputstring.clear();
									  char filename[MAX_PATH];
									  GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH);
									  if(PCSX2LoadLuaCode(filename))
										  WinLuaOnStart();
								  }
		}       break;

		case IDC_BUTTON_LUASTOP:
		{
								   PCSX2LuaStop();
								   WinLuaOnStop();
		}       break;

		case IDC_BUTTON_LUAEDIT:
		{
								   char Str_Tmp[1024];
								   SendDlgItemMessage(hDlg, IDC_EDIT_LUAPATH, WM_GETTEXT, (WPARAM)512, (LPARAM)Str_Tmp);
								   // tell the OS to open the file with its associated editor,
								   // without blocking on it or leaving a command window open.
								   if ((int)ShellExecute(NULL, "edit", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
								   if ((int)ShellExecute(NULL, "open", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
									   ShellExecute(NULL, NULL, "notepad", Str_Tmp, NULL, SW_SHOWNORMAL);
		}       break;

		case IDC_BUTTON_LUABROWSE:
		{

									 //systemSoundClearBuffer();

									 //CString filter = winResLoadFilter(IDS_FILTER_LUA);
									 //CString title = winResLoadString(IDS_SELECT_LUA_NAME);

									 //CString luaName = winGetDestFilename(theApp.gameFilename, IDS_LUA_DIR, ".lua");
									 //CString luaDir = winGetDestDir(IDS_LUA_DIR);

									 //filter.Replace('|', '\000');
									 //                              char *p = filter.GetBuffer(0);
									 //                              while ((p = strchr(p, '|')) != NULL)
									 //                                      *p++ = 0;

									 char filenamebuffer[MAX_PATH];
									 ZeroMemory(filenamebuffer, MAX_PATH);
									 OPENFILENAME  ofn;
									 ZeroMemory((LPVOID)&ofn, sizeof(OPENFILENAME));
									 ofn.lpstrFile = filenamebuffer;
									 ofn.nMaxFile = MAX_PATH;
									 ofn.lStructSize = sizeof(OPENFILENAME);
									 ofn.hwndOwner = hDlg;
									 ofn.lpstrFilter = "Lua Script(*.lua)\0*.lua\0All files(*.*)\0*.*\0\0";
									 ofn.nFilterIndex = 0;
									 //ofn.lpstrInitialDir = "";
									 ofn.lpstrTitle = "choose lua file";
									 ofn.lpstrDefExt = "lua";
									 ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ENABLESIZING | OFN_EXPLORER; // hide previously-ignored read-only checkbox (the real read-only box is in the open-movie dialog itself)
									 if (GetOpenFileName(&ofn))
									 {
										 SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), filenamebuffer);
									 }

									 return true;
		}       break;

		case IDC_EDIT_LUAPATH:
		{
								 char filename[MAX_PATH];
								 GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH);
								 FILE* file = fopen(filename, "rb");
								 EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUAEDIT), file != NULL);
								 if (file)
									 fclose(file);
		}       break;

		case IDC_LUACONSOLE_CHOOSEFONT:
		{
										  CHOOSEFONT cf;

										  ZeroMemory(&cf, sizeof(cf));
										  cf.lStructSize = sizeof(CHOOSEFONT);
										  cf.hwndOwner = hDlg;
										  cf.lpLogFont = &LuaConsoleLogFont;
										  cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
										  if (ChooseFont(&cf)) {
											  if (hFont) {
												  DeleteObject(hFont);
												  hFont = NULL;
											  }
											  hFont = CreateFontIndirect(&LuaConsoleLogFont);
											  if (hFont)
												  SendDlgItemMessage(hDlg, IDC_LUACONSOLE, WM_SETFONT, (WPARAM)hFont, 0);
										  }
		}       break;

		case IDC_LUACONSOLE_CLEAR:
		{
									 SetWindowText(GetDlgItem(hDlg, IDC_LUACONSOLE), "");
		}       break;
		case IDC_LUACONSOLE_UPDATE:
		{
									  /*排他制御してやらないと、出力したい文字列が途切れたりしてしまうのです。。。*/
									  lockLuamutex();
									  if (!LuaConsoleHWnd || consoleputstring.empty()){
										  unlockLuamutex();
										  break;
									  }
									  HWND hConsole = LuaConsoleHWnd;

									  int length = GetWindowTextLength(hConsole);
									  if (length >= 250000)
									  {
										  // discard first half of text if it's getting too long
										  SendMessage(hConsole, EM_SETSEL, 0, length / 2);
										  SendMessage(hConsole, EM_REPLACESEL, false, (LPARAM)"");
										  length = GetWindowTextLength(hConsole);
									  }
									  SendMessage(hConsole, EM_SETSEL, length, length);

									  //LuaPerWindowInfo& info = LuaWindowInfo[hDlg];
									  {
										  consoleputstring = Replace(consoleputstring, "\n", "\r\n");
										  SendMessage(hConsole, EM_REPLACESEL, false, (LPARAM)consoleputstring.c_str());
									  }
									  consoleputstring.clear();
									  unlockLuamutex();
		}		break;

		} // switch (LOWORD(wParam))
		break;

	case WM_CLOSE: {
					   //SendMessage(hDlg, WM_DESTROY, 0, 0);
					   DestroyWindow(hDmyWnd);
	}       break;

	case WM_DESTROY: {
						 PCSX2LuaStop();
						 DragAcceptFiles(hDlg, FALSE);
						 if (hFont) {
							 DeleteObject(hFont);
							 hFont = NULL;
						 }
						 LuaConsoleHWnd = NULL;
						 hLuaDlg = NULL;
						 hDmyWnd = NULL;
	}       break;

	case WM_DROPFILES: {
						   HDROP hDrop;
						   //UINT fileNo;
						   UINT fileCount;
						   char filename[_MAX_PATH];

						   hDrop = (HDROP)wParam;
						   fileCount = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
						   if (fileCount > 0) {
							   DragQueryFile(hDrop, 0, filename, sizeof(filename));
							   SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), filename);
						   }
						   DragFinish(hDrop);
						   return true;
	}       break;

	}

	return false;

}
Example #4
0
void ClearLog(HWND hwnd) {
    SetDlgItemText(hwnd, IDC_LOGWIN, "");
}
INT_PTR CALLBACK PhpHandleGeneralDlgProc(
    _In_ HWND hwndDlg,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam
    )
{
    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            LPPROPSHEETPAGE propSheetPage = (LPPROPSHEETPAGE)lParam;
            PHANDLE_PROPERTIES_CONTEXT context = (PHANDLE_PROPERTIES_CONTEXT)propSheetPage->lParam;
            PPH_ACCESS_ENTRY accessEntries;
            ULONG numberOfAccessEntries;
            HANDLE processHandle;
            OBJECT_BASIC_INFORMATION basicInfo;
            BOOLEAN haveBasicInfo = FALSE;

            SetProp(hwndDlg, PhMakeContextAtom(), (HANDLE)context);

            SetDlgItemText(hwndDlg, IDC_NAME, PhGetString(context->HandleItem->BestObjectName));
            SetDlgItemText(hwndDlg, IDC_TYPE, context->HandleItem->TypeName->Buffer);
            SetDlgItemText(hwndDlg, IDC_ADDRESS, context->HandleItem->ObjectString);

            if (PhGetAccessEntries(
                context->HandleItem->TypeName->Buffer,
                &accessEntries,
                &numberOfAccessEntries
                ))
            {
                PPH_STRING accessString;
                PPH_STRING grantedAccessString;

                accessString = PH_AUTO(PhGetAccessString(
                    context->HandleItem->GrantedAccess,
                    accessEntries,
                    numberOfAccessEntries
                    ));

                if (accessString->Length != 0)
                {
                    grantedAccessString = PhaFormatString(
                        L"%s (%s)",
                        context->HandleItem->GrantedAccessString,
                        accessString->Buffer
                        );
                    SetDlgItemText(hwndDlg, IDC_GRANTED_ACCESS, grantedAccessString->Buffer);
                }
                else
                {
                    SetDlgItemText(hwndDlg, IDC_GRANTED_ACCESS, context->HandleItem->GrantedAccessString);
                }

                PhFree(accessEntries);
            }
            else
            {
                SetDlgItemText(hwndDlg, IDC_GRANTED_ACCESS, context->HandleItem->GrantedAccessString);
            }

            if (NT_SUCCESS(PhOpenProcess(
                &processHandle,
                PROCESS_DUP_HANDLE,
                context->ProcessId
                )))
            {
                if (NT_SUCCESS(PhGetHandleInformation(
                    processHandle,
                    context->HandleItem->Handle,
                    -1,
                    &basicInfo,
                    NULL,
                    NULL,
                    NULL
                    )))
                {
                    SetDlgItemInt(hwndDlg, IDC_REFERENCES, basicInfo.PointerCount, FALSE);
                    SetDlgItemInt(hwndDlg, IDC_HANDLES, basicInfo.HandleCount, FALSE);
                    SetDlgItemInt(hwndDlg, IDC_PAGED, basicInfo.PagedPoolCharge, FALSE);
                    SetDlgItemInt(hwndDlg, IDC_NONPAGED, basicInfo.NonPagedPoolCharge, FALSE);

                    haveBasicInfo = TRUE;
                }

                NtClose(processHandle);
            }

            if (!haveBasicInfo)
            {
                SetDlgItemText(hwndDlg, IDC_REFERENCES, L"Unknown");
                SetDlgItemText(hwndDlg, IDC_HANDLES, L"Unknown");
                SetDlgItemText(hwndDlg, IDC_PAGED, L"Unknown");
                SetDlgItemText(hwndDlg, IDC_NONPAGED, L"Unknown");
            }
        }
        break;
    case WM_DESTROY:
        {
            RemoveProp(hwndDlg, PhMakeContextAtom());
        }
        break;
    case WM_NOTIFY:
        {
            LPNMHDR header = (LPNMHDR)lParam;

            switch (header->code)
            {
            case PSN_QUERYINITIALFOCUS:
                {
                    SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)GetDlgItem(hwndDlg, IDC_BASICINFORMATION));
                }
                return TRUE;
            }
        }
        break;
    }

    return FALSE;
}
DWORD WINAPI DumpThreadProc( LPVOID lpParameter)
{
	unsigned int i,j,k,m,n,ret;
	int l;
	FD_SCAN_PARAMS sp;
	FD_SCAN_RESULT *sr;
	FD_READ_WRITE_PARAMS rwp;
	FD_CMD_RESULT cmdr;
	SECTORCONFIG* sectorconfig;
	floppydumperparams * params;
	unsigned char * tempstr;
	unsigned char * trackbuffer;
	unsigned char b;
	int tracksize,retry,gap3len,trackformat;
	unsigned long rotationtime,rpm,bitrate,tracklen;
	unsigned long total_size,numberofsector_read,number_of_bad_sector;
	
	CYLINDER* currentcylinder;
	SIDE* currentside;
	
	
	params=(floppydumperparams*)lpParameter;
	
	params->flopemu->hxc_printf(MSG_DEBUG,"Starting Floppy dump...");
	
	tempstr=(char*)malloc(1024);
	
	trackbuffer=0;
	tracksize=0;
	
	if(checkversion())
	{
		if(opendevice(params->drive))
		{

			total_size=0;
			numberofsector_read=0;
			number_of_bad_sector=0;

			sr=malloc(sizeof(FD_ID_HEADER)*256 + 1);
			
			params->floppydisk->floppyBitRate=VARIABLEBITRATE;
			
			params->floppydisk->floppyNumberOfSide=params->number_of_side;
			params->floppydisk->floppyNumberOfTrack=params->number_of_track;
			params->floppydisk->floppySectorPerTrack=-1;

			seek(0, 0);

			sprintf(tempstr,"Checking drive RPM...");
			SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
					
			rotationtime=200000;
			if (!DeviceIoControl(h, IOCTL_FD_GET_TRACK_TIME, 0, 0, &rotationtime, sizeof(rotationtime), &ret, NULL))
			{
				sprintf(tempstr,"Error during RPM checking :%d ",GetLastError());
				SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
				params->flopemu->hxc_printf(MSG_DEBUG,"Leaving Floppy dump: IOCTL_FD_GET_TRACK_TIME error %d...",GetLastError());
				closedevice();
				free(tempstr);

				params->status=0;
				return 0;
			}
			
			params->floppydisk->tracks=(CYLINDER**)malloc(sizeof(CYLINDER*)*params->floppydisk->floppyNumberOfTrack);
			
			rpm=60000/(rotationtime/1000);
			
			params->flopemu->hxc_printf(MSG_DEBUG,"Drive RPM: %d",rpm);
			sprintf(tempstr,"Drive RPM: %d",rpm);
			SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
			
			if(rpm>280 && rpm<320) rpm=300;
			if(rpm>340 && rpm<380) rpm=360;
			
			bitrate=500000;
			
			sprintf(tempstr,"Starting reading disk...");
			SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
			
			for(i=0;i<params->floppydisk->floppyNumberOfTrack;i++)
			{
				params->floppydisk->tracks[i]=(CYLINDER*)malloc(sizeof(CYLINDER));
				currentcylinder=params->floppydisk->tracks[i];
				currentcylinder->number_of_side=params->floppydisk->floppyNumberOfSide;
				currentcylinder->sides=(SIDE**)malloc(sizeof(SIDE*)*currentcylinder->number_of_side);
				memset(currentcylinder->sides,0,sizeof(SIDE*)*currentcylinder->number_of_side);
				
				for(j=0;j<params->floppydisk->floppyNumberOfSide;j++)
				{
					
					currentcylinder->floppyRPM=rpm;
					currentcylinder->sides[j]=malloc(sizeof(SIDE));
					memset(currentcylinder->sides[j],0,sizeof(SIDE));
					currentside=currentcylinder->sides[j];
					
					seek(i*params->double_step, j);
					
					l=0;
					do
					{
						m=0;
						while(tm[m].index!=l)
						{
							m++;
						}
						
						memset(sr,0,sizeof(FD_ID_HEADER)*256 + 1);
						
						if(tm[m].encoding_mode)
						{
							sp.flags=FD_OPTION_MFM;
							trackformat=ISOFORMAT_DD;
						}
						else
						{
							sp.flags=0x00;
							trackformat=ISOFORMAT_SD;
						}
						
						sp.head=j;
						
						bitrate=tm[m].bitrate;
						b = tm[m].bitrate_code;
						if (!DeviceIoControl(h, IOCTL_FD_SET_DATA_RATE, &b, sizeof b, NULL, 0, &ret, NULL)) 
						{
							printf("IOCTL_FD_SET_DATA_RATE=%d failed err=%d\n", b, GetLastError());
							closedevice();
							params->status=0;
							return 0;
						}
						
						if (!DeviceIoControl(h, IOCTL_FD_SCAN_TRACK, &sp, sizeof sp, sr, sizeof(FD_ID_HEADER)*256 + 1, &ret, NULL))
						{
							params->flopemu->hxc_printf(MSG_DEBUG,"IOCTL_FD_SCAN_TRACK error %d ...",GetLastError());
						}
						
						if(sr->count)
						{
							n=0;
							while(tm[n].index)
							{
								n++;
							}
							
							k=tm[n].index;
							tm[n].index=tm[m].index;		
							tm[m].index=k;
						}
						else
						{
							DeviceIoControl(h, IOCTL_FD_RESET, NULL, 0, NULL, 0, &ret, NULL);
						}
						
						l++;
					}while(l<8 && !sr->count);
					
					sectorconfig=(SECTORCONFIG*)malloc(sizeof(SECTORCONFIG)*sr->count);
					memset(sectorconfig,0,sizeof(SECTORCONFIG)*sr->count);
					
					params->flopemu->hxc_printf(MSG_DEBUG,"Track %d side %d: %d sectors found : ",i,j,sr->count);
					
					seek(i*params->double_step, j);
					
					if( sr->Header[0].cyl==sr->Header[sr->count-1].cyl && 
						sr->Header[0].head==sr->Header[sr->count-1].head && 
						sr->Header[0].sector==sr->Header[sr->count-1].sector && 
						sr->Header[0].size==sr->Header[sr->count-1].size 
						)
					{
						sr->count--;
					}

					for(k=0;k<sr->count;k++)
					{
						params->flopemu->hxc_printf(MSG_DEBUG,"Sector %.2d, Track ID: %.3d, Head ID:%d, Size: %d bytes, Bitrate:%dkbits/s, %s",sr->Header[k].sector,sr->Header[k].cyl,sr->Header[k].head,128<<sr->Header[k].size,bitrate/1000,trackformat==ISOFORMAT_SD?"FM":"MFM");
						
						
						if(tm[m].encoding_mode)
						{
							rwp.flags=FD_OPTION_MFM;
						}
						else
						{
							rwp.flags=0x00;
						}
						rwp.cyl=sr->Header[k].cyl;
						rwp.phead=j;
						rwp.head=sr->Header[k].head;
						rwp.sector=sr->Header[k].sector;
						rwp.size=sr->Header[k].size;
						rwp.eot=sr->Header[k].sector+1;
						rwp.gap=10;
						if((128<<sr->Header[k].size)>128)
						{
							rwp.datalen=255;
						}
						else
						{
							rwp.datalen=128;
						}
						
						retry=5;
						trackbuffer=realloc(trackbuffer,tracksize+(128<<sr->Header[k].size));
						do
						{
							retry--;
						}while(!DeviceIoControl(h, IOCTL_FDCMD_READ_DATA, &rwp, sizeof rwp, &trackbuffer[tracksize], 128<<sr->Header[k].size, &ret, NULL) && retry);
						if(!retry)
						{	
							DeviceIoControl(h, IOCTL_FD_GET_RESULT,0, 0, &cmdr, sizeof(FD_CMD_RESULT), &ret, NULL);
							params->flopemu->hxc_printf(MSG_DEBUG,"Read Error ! ST0: %.2x, ST1: %.2x, ST2: %.2x",cmdr.st0,cmdr.st1,cmdr.st2);
							number_of_bad_sector++;
						}
					
						
						total_size=total_size+(128<<sr->Header[k].size);
						numberofsector_read++;

						sectorconfig[k].cylinder=sr->Header[k].cyl;
						sectorconfig[k].head=sr->Header[k].head;
						sectorconfig[k].sector=sr->Header[k].sector;
						sectorconfig[k].sectorsize=(128<<sr->Header[k].size);
						
						
						tracksize=tracksize+(128<<sr->Header[k].size);

						sprintf(tempstr,"%d Sector(s) Read, %d bytes, %d Bad sector(s)",numberofsector_read,total_size,number_of_bad_sector);
						SetDlgItemText(params->windowshwd,IDC_EDIT2,tempstr);

					}
					
					currentside->number_of_sector=sr->count;
					currentside->bitrate=bitrate;
					
					tracklen=(bitrate/(rpm/60))/4;

					currentside->tracklen=tracklen;
					
					currentside->databuffer=malloc(currentside->tracklen);
					memset(currentside->databuffer,0,currentside->tracklen);
					
					currentside->flakybitsbuffer=0;
					
					currentside->timingbuffer=0;
					currentside->indexbuffer=malloc(currentside->tracklen);
					memset(currentside->indexbuffer,0,currentside->tracklen);						
					fillindex(currentside->tracklen-1,currentside,2500,TRUE,1);
					
					gap3len=20;
					
					BuildISOTrack(params->flopemu,trackformat,currentside->number_of_sector,1,512,j,i,gap3len,trackbuffer,currentside->databuffer,&currentside->tracklen,0,0,sectorconfig);
					
					sprintf(tempstr,"Track %d side %d: %d sectors, %dkbits/s, %s",i,j,sr->count,bitrate/1000,trackformat==ISOFORMAT_SD?"FM":"MFM");
					SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
					
					free(sectorconfig);
					free(trackbuffer);
					trackbuffer=0;
					tracksize=0;
				}
			}
			
			closedevice();

			sprintf(tempstr,"Done !");
			SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
			sprintf(tempstr,"%d Sector(s) Read, %d bytes, %d Bad sector(s)",numberofsector_read,total_size,number_of_bad_sector);
			SetDlgItemText(params->windowshwd,IDC_EDIT2,tempstr);
					
			params->flopemu->hxc_printf(MSG_DEBUG,"Done ! %d sectors read, %d bad sector(s), %d bytes read",numberofsector_read,number_of_bad_sector,total_size);
		
			loadfloppy("Floppy Dump",params->floppydisk,0);


			free(tempstr);
			

			
			params->flopemu->hxc_printf(MSG_DEBUG,"Leaving Floppy dump...");
			
			params->status=0;
			return 0;

		}
	
	}

	sprintf(tempstr,"Error while opening fdrawcmd, see: http://simonowen.com/fdrawcmd");
	SetDlgItemText(params->windowshwd,IDC_EDIT1,tempstr);
	
	free(tempstr);

	params->flopemu->hxc_printf(MSG_DEBUG,"Leaving Floppy dump...");
	
	params->status=0;
	return 0;
	
}
Example #7
0
LONG APIENTRY EndTaskDlgProc(
    HWND hwndDlg,
    UINT msg,
    UINT wParam,
    LONG lParam)
{
    ENDDLGPARAMS* pedp;
    LARGE_INTEGER li;
    WCHAR achFormat[CCHBODYMAX];
    WCHAR achText[CCHBODYMAX];
    DWORD dwData;
    USERTHREAD_FLAGS Flags;

    switch (msg) {
    case WM_INITDIALOG:
        pedp = (ENDDLGPARAMS*)lParam;

        /*
         * Save this for later revalidation.
         */
        SetWindowLong(hwndDlg, GWL_USERDATA, (DWORD)pedp->h);
        SetWindowLong(hwndDlg, DWL_USER, (DWORD)pedp->type);

        SetWindowText(hwndDlg, pedp->pszTitle);

        /*
         * Update text that says how long we'll wait.
         */
        GetDlgItemText(hwndDlg, IDIGNORE, achFormat, CCHBODYMAX);
        wsprintf(achText, achFormat, pedp->cSeconds);
        SetDlgItemText(hwndDlg, IDIGNORE, achText);

        /*
         * Make this dialog top most and foreground.
         */
        Flags.dwFlags = TIF_ALLOWFOREGROUNDACTIVATE;
        Flags.dwMask = TIF_ALLOWFOREGROUNDACTIVATE;
        NtUserSetInformationThread(NtCurrentThread(), UserThreadFlags,
                &Flags, sizeof(Flags));
        SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0,
                SWP_NOMOVE | SWP_NOSIZE);

        /*
         * Set this timer so every 1/2 a second we can see if this app
         * has gone away.
         */
        SetTimer(hwndDlg, 5, 500, NULL);
        return TRUE;

    case WM_TIMER:
        /*
         * If shutdown has been cancelled, bring down the dialog.
         */
        li.QuadPart  = 0;
        if (NtWaitForSingleObject(heventCancel, FALSE, &li) == 0) {
            EndDialog(hwndDlg, IDCANCEL);
            break;
        }

        dwData = GetWindowLong(hwndDlg, GWL_USERDATA);
        if (GetWindowLong(hwndDlg, DWL_USER) == TYPE_CONSOLE_ID) {

            /*
             * If it's the console calling us, check if the thread or process
             * handle is still valid. If not, bring down the dialog.
             */
            if (WaitForSingleObject((HANDLE)dwData, 0) != 0)
                break;
        } else if (!(((PCSR_THREAD)dwData)->Flags & CSR_THREAD_DESTROYED)) {

            /*
             * If the thread is marked as destroyed, bring down the dialog.
             */
            break;
        }

        /*
         * This'll cause the dialog to go away and the wait for this app to
         * close to return.
         */
        EndDialog(hwndDlg, IDRETRY);
        break;

    case WM_CLOSE:
        /*
         * Assume WM_CLOSE means cancel shutdown
         */
        wParam = IDCANCEL;
        /*
         * falls through...
         */

    case WM_COMMAND:
        EndDialog(hwndDlg, LOWORD(wParam));
        break;
    }

    return FALSE;
}
Example #8
0
// Window proc for dialog
LRESULT CALLBACK
DownloadDlgProc(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_INITDIALOG:
        GetPrivateProfileString("Strings",
                                "Status File Info",
                                "",
                                gszFileInfo,
                                sizeof(gszFileInfo),
                                szFileIniConfig);
        DisableSystemMenuItems(hWndDlg, FALSE);
        if(gbShowDownloadRetryMsg)
            SetDlgItemText(hWndDlg, IDC_MESSAGE0, diDownload.szMessageRetry0);
        else
            SetDlgItemText(hWndDlg, IDC_MESSAGE0, diDownload.szMessageDownload0);

        EnableWindow(GetDlgItem(hWndDlg, IDRESUME), FALSE);
        SetDlgItemText(hWndDlg, IDC_STATIC1, sgInstallGui.szStatus);
        SetDlgItemText(hWndDlg, IDC_STATIC2, sgInstallGui.szFile);
        SetDlgItemText(hWndDlg, IDC_STATIC4, sgInstallGui.szTo);
        SetDlgItemText(hWndDlg, IDC_STATIC3, sgInstallGui.szUrl);
        SetDlgItemText(hWndDlg, IDCANCEL, sgInstallGui.szCancel_);
        SetDlgItemText(hWndDlg, IDPAUSE, sgInstallGui.szPause_);
        SetDlgItemText(hWndDlg, IDRESUME, sgInstallGui.szResume_);
        SendDlgItemMessage (hWndDlg, IDC_STATIC1, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
        SendDlgItemMessage (hWndDlg, IDC_STATIC2, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
        SendDlgItemMessage (hWndDlg, IDC_STATIC3, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
        SendDlgItemMessage (hWndDlg, IDCANCEL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
        SendDlgItemMessage (hWndDlg, IDPAUSE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
        SendDlgItemMessage (hWndDlg, IDRESUME, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
        SendDlgItemMessage (hWndDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
        SendDlgItemMessage (hWndDlg, IDC_STATUS_STATUS, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
        SendDlgItemMessage (hWndDlg, IDC_STATUS_FILE, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
        SendDlgItemMessage (hWndDlg, IDC_STATUS_URL, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
        SendDlgItemMessage (hWndDlg, IDC_STATUS_TO, WM_SETFONT, (WPARAM)sgInstallGui.definedFont, 0L);
        RepositionWindow(hWndDlg, BANNER_IMAGE_DOWNLOAD);
        ClosePreviousDialog();
        return FALSE;

    case WM_SIZE:
        switch(wParam)
        {
        case SIZE_MINIMIZED:
            SetMinimizedDownloadTitle((int)GetPercentSoFar());
            gbDlgDownloadMinimized = TRUE;
            gbDlgDownloadJustMinimized = TRUE;
            break;

        case SIZE_RESTORED:
            SetStatusUrl();
            SetRestoredDownloadTitle();
            gbDlgDownloadMinimized = FALSE;
            break;
        }
        return(FALSE);

    case WM_COMMAND:
        switch(LOWORD(wParam))
        {
        case IDCANCEL:
            if(AskCancelDlg(hWndDlg))
                gdwDownloadDialogStatus = CS_CANCEL;
            break;

        case IDPAUSE:
            if(!gtiPaused.bTickStarted)
            {
                gtiPaused.dwTickBegin          = GetTickCount();
                gtiPaused.bTickStarted         = TRUE;
                gtiPaused.bTickDownloadResumed = FALSE;
            }

            EnableWindow(GetDlgItem(hWndDlg, IDPAUSE),  FALSE);
            EnableWindow(GetDlgItem(hWndDlg, IDRESUME), TRUE);
            gdwDownloadDialogStatus = CS_PAUSE;
            break;

        case IDRESUME:
            gtiPaused.dwTickEnd = GetTickCount();
            gtiPaused.dwTickDif = GetTickDif(gtiPaused.dwTickEnd,
                                             gtiPaused.dwTickBegin);
            gtiPaused.bTickDownloadResumed = TRUE;

            EnableWindow(GetDlgItem(hWndDlg, IDRESUME), FALSE);
            EnableWindow(GetDlgItem(hWndDlg, IDPAUSE),  TRUE);
            gdwDownloadDialogStatus = CS_NONE;
            break;

        default:
            break;
        }
        return(TRUE);
    }

    return(FALSE);  // didn't handle the message
}
Example #9
0
void SetStatusStatus(void)
{
    char        szStatusStatusLine[MAX_BUF_MEDIUM];
    char        szCurrentStatusInfo[MAX_BUF_MEDIUM];
    char        szPercentString[MAX_BUF_MEDIUM];
    char        szPercentageCompleted[MAX_BUF_MEDIUM];
    static long lModLastValue = 0;
    double        dRate;
    static double dRateCounter;
    DWORD         dwTickNow;
    DWORD         dwTickDif;
    DWORD         dwKBytesSoFar;
    DWORD         dwRoundedRate;
    char          szTimeLeft[MAX_BUF_TINY];

    /* If the user just clicked on the Resume button, then the time lapsed
     * between gdwTickStart and when the Resume button was clicked needs to
     * be subtracted taken into account when calculating dwTickDif.  So
     * "this" lapsed time needs to be added to gdwTickStart. */
    if(gtiPaused.bTickDownloadResumed)
    {
        gdwTickStart = AddToTick(gdwTickStart, gtiPaused.dwTickDif);
        InitTickInfo();
    }

    /* GetTickCount() returns time in milliseconds.  This is more accurate,
     * which will allow us to get at a 2 decimal precision value for the
     * download rate. */
    dwTickNow = GetTickCount();
    if((gdwTickStart == 0) && gbStartTickCounter)
        dwTickNow = gdwTickStart = GetTickCount();

    dwTickDif = GetTickDif(dwTickNow, gdwTickStart);

    /* Only update the UI every UPDATE_INTERVAL_STATUS interval,
     * which is currently set to 1 sec. */
    if(!CheckInterval(&lModLastValue, UPDATE_INTERVAL_STATUS))
        return;

    if(glAbsoluteBytesSoFar == 0)
        dRateCounter = 0.0;
    else
        dRateCounter = dwTickDif / 1000;

    if(dRateCounter == 0.0)
        dRate = 0.0;
    else
        dRate = (glAbsoluteBytesSoFar - glBytesResumedFrom) / dRateCounter / 1024;

    dwKBytesSoFar = glAbsoluteBytesSoFar / 1024;

    /* Use a rate that is rounded to the nearest integer.  If dRate used directly,
     * the "Time Left" will jump around quite a bit due to the rate usually
     * varying up and down by quite a bit. The rounded rate give a "more linear"
     * count down of the "Time Left". */
    dwRoundedRate = RoundDouble(dRate);
    if(dwRoundedRate > 0)
        GetTimeLeft((glTotalKb - dwKBytesSoFar) / dwRoundedRate,
                    szTimeLeft,
                    sizeof(szTimeLeft));
    else
        lstrcpy(szTimeLeft, "00:00:00");

    if(!gbShowDownloadRetryMsg)
    {
        GetPrivateProfileString("Strings",
                                "Status Download",
                                "",
                                szStatusStatusLine,
                                sizeof(szStatusStatusLine),
                                szFileIniConfig);
        if(*szStatusStatusLine != '\0')
            sprintf(szCurrentStatusInfo,
                    szStatusStatusLine,
                    szTimeLeft,
                    dRate,
                    dwKBytesSoFar,
                    glTotalKb);
        else
            sprintf(szCurrentStatusInfo,
                    "%s at %.2fKB/sec (%uKB of %uKB downloaded)",
                    szTimeLeft,
                    dRate,
                    dwKBytesSoFar,
                    glTotalKb);
    }
    else
    {
        GetPrivateProfileString("Strings",
                                "Status Retry",
                                "",
                                szStatusStatusLine,
                                sizeof(szStatusStatusLine),
                                szFileIniConfig);
        if(*szStatusStatusLine != '\0')
            sprintf(szCurrentStatusInfo,
                    szStatusStatusLine,
                    szTimeLeft,
                    dRate,
                    dwKBytesSoFar,
                    glTotalKb);
        else
            sprintf(szCurrentStatusInfo,
                    "%s at %.2KB/sec (%uKB of %uKB downloaded)",
                    szTimeLeft,
                    dRate,
                    dwKBytesSoFar,
                    glTotalKb);
    }

    GetPrivateProfileString("Strings",
                            "Status Percentage Completed",
                            "",
                            szPercentageCompleted,
                            sizeof(szPercentageCompleted),
                            szFileIniConfig);
    wsprintf(szPercentString, szPercentageCompleted, (int)GetPercentSoFar());

    /* Set the download dialog title */
    SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS_STATUS, szCurrentStatusInfo);
    SetDlgItemText(dlgInfo.hWndDlg, IDC_PERCENTAGE, szPercentString);
}
Example #10
0
void Browse_OnInitDialog (HWND hDlg)
{
   LPBROWSE_PARAMS lpp;
   if ((lpp = (LPBROWSE_PARAMS)GetWindowLongPtr (hDlg, DWLP_USER)) != NULL)
      {
      // First, the text of the dialog is woefully ugly right now. Put
      // in the strings which the caller supplied.
      //
      TCHAR szText[ cchRESOURCE ];
      GetString (szText, lpp->idsTitle);
      SetWindowText (hDlg, szText);

      GetString (szText, lpp->idsPrompt);
      SetDlgItemText (hDlg, IDC_BROWSE_TYPE, szText);

      SetDlgItemText (hDlg, IDC_BROWSE_NAMED, lpp->szName);

      SetDlgItemText (hDlg, IDC_BROWSE_PATTERN, TEXT(""));

      ULONG status;
      asc_CellNameGet_Fast (g.idClient, g.idCell, szText, &status);
      SetDlgItemText (hDlg, IDC_BROWSE_CELL, szText);
      EnableWindow (GetDlgItem (hDlg, IDC_BROWSE_CELL), FALSE);

      if (GetDlgItem (hDlg, IDC_BROWSE_CHECK))
         {
         if (lpp->idsCheck == 0)
            ShowWindow (GetDlgItem (hDlg, IDC_BROWSE_CHECK), FALSE);
         else
            {
            GetString (szText, lpp->idsCheck);
            SetDlgItemText (hDlg, IDC_BROWSE_CHECK, szText);
            }

         CheckDlgButton (hDlg, IDC_BROWSE_CHECK, (lpp->pObjectsToSkip) ? TRUE : FALSE);
         }

      if (GetDlgItem (hDlg, IDC_BROWSE_COMBO))
         {
         HWND hCombo = GetDlgItem (hDlg, IDC_BROWSE_COMBO);
         LPARAM lpSelect = 0;
         CB_StartChange (hCombo, TRUE);

         if (lpp->TypeToShow & TYPE_USER)
            {
            CB_AddItem (hCombo, IDS_SHOW_USERS, TYPE_USER);
            if (!lpSelect)
               lpSelect = TYPE_USER;
            }

         if (lpp->TypeToShow & TYPE_GROUP)
            {
            CB_AddItem (hCombo, IDS_SHOW_GROUPS, TYPE_GROUP);
            if (!lpSelect)
               lpSelect = TYPE_GROUP;
            }

         CB_EndChange (hCombo, lpSelect);
         }

      // If the caller requested that we disallow multiple selection,
      // change the fastlist's styles...
      //
      if (!lpp->fAllowMultiple)
         {
         DWORD dwStyle = GetWindowLong (GetDlgItem (hDlg, IDC_BROWSE_LIST), GWL_STYLE);
         dwStyle &= ~(FLS_SELECTION_MULTIPLE);
         SetWindowLong (GetDlgItem (hDlg, IDC_BROWSE_LIST), GWL_STYLE, dwStyle);
         }

      // Finally, update the listbox to show a valid list of users/groups.
      // Oh--since we're in initdialog, add an imagelist to the window too.
      //
      FastList_SetImageLists (GetDlgItem (hDlg, IDC_BROWSE_LIST), AfsAppLib_CreateImageList(FALSE), NULL);
      Browse_UpdateDialog (hDlg);
      }
}
Example #11
0
BOOL CALLBACK Browse_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
   LPBROWSE_PARAMS lpp;
   if ((lpp = (LPBROWSE_PARAMS)GetWindowLongPtr (hDlg, DWLP_USER)) != NULL)
      {
      if (AfsAppLib_HandleHelp (lpp->iddForHelp, hDlg, msg, wp, lp))
         return FALSE;
      }

   switch (msg)
      {
      case WM_INITDIALOG:
         SetWindowLongPtr (hDlg, DWLP_USER, lp);
         Browse_OnInitDialog (hDlg);
         l.dwTickLastType = 0;
         break;

      case WM_ENDTASK:
         LPTASKPACKET ptp;
         if ((ptp = (LPTASKPACKET)lp) != NULL)
            {
            if ((ptp->idTask == taskUSER_ENUM) || (ptp->idTask == taskGROUP_ENUM))
               Browse_OnEndTask_EnumObjects (hDlg, ptp);
            else if (ptp->idTask == taskLIST_TRANSLATE)
               Browse_OnEndTask_Translate (hDlg, ptp);
            FreeTaskPacket (ptp);
            }
         break;

      case WM_TIMER:
         switch (wp)
            {
            case ID_SEARCH_TIMER:
               if ( (l.dwTickLastType) && (GetTickCount() > l.dwTickLastType + msecSEARCH_TIMER) )
                  {
                  KillTimer (hDlg, ID_SEARCH_TIMER);
                  Browse_UpdateDialog (hDlg);
                  }
               break;
            }
         break;

      case WM_COMMAND:
         switch (LOWORD(wp))
            {
            case IDC_BROWSE_SELECT:
               Browse_OnOK (hDlg);
               break;

            case IDCANCEL:
               EndDialog (hDlg, IDCANCEL);
               break;

            case IDC_BROWSE_CHECK:
               Browse_UpdateDialog (hDlg);
               break;

            case IDC_BROWSE_COMBO:
               if (HIWORD(wp) == CBN_SELCHANGE)
                  {
                  SetDlgItemText (hDlg, IDC_BROWSE_NAMED, TEXT(""));
                  Browse_UpdateDialog (hDlg);
                  }
               break;

            case IDC_BROWSE_RESTART:
               Browse_UpdateDialog (hDlg);
               PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (hDlg, IDC_BROWSE_NAMED), (LPARAM)TRUE);
               break;

            case IDC_BROWSE_NAMED:
               if (HIWORD(wp) == EN_UPDATE)  // has the user hit Enter here?
                  {
                  TCHAR szTest[ 1024 ];
                  GetDlgItemText (hDlg, IDC_BROWSE_NAMED, szTest, 1024);

                  if ((lstrlen (szTest)) && (szTest[lstrlen(szTest)-1]==TEXT('\n')))
                     {
                     szTest[ lstrlen(szTest)-1 ] = TEXT('\0');
                     if ((lstrlen (szTest)) && (szTest[lstrlen(szTest)-1]==TEXT('\r')))
                        szTest[ lstrlen(szTest)-1 ] = TEXT('\0');

                     SetDlgItemText (hDlg, IDC_BROWSE_NAMED, szTest);
                     PostMessage (hDlg, WM_COMMAND, MAKELONG(IDC_BROWSE_SELECT,BN_CLICKED), (LPARAM)GetDlgItem(hDlg,IDC_BROWSE_SELECT));
                     }
                  }
               break;

            case IDC_BROWSE_PATTERN:
               if (HIWORD(wp) == EN_UPDATE)
                  {
                  l.dwTickLastType = GetTickCount();
                  KillTimer (hDlg, ID_SEARCH_TIMER);
                  SetTimer (hDlg, ID_SEARCH_TIMER, msecSEARCH_TIMER +15, NULL);
                  }
               break;
            }
         break;

      case WM_NOTIFY:
         switch (((LPNMHDR)lp)->code)
            {
            case FLN_ITEMSELECT:
               Browse_OnSelect (hDlg);
               break;

            case FLN_LDBLCLICK:
               PostMessage (hDlg, WM_COMMAND, MAKELONG(IDC_BROWSE_SELECT,BN_CLICKED), (LPARAM)GetDlgItem (hDlg, IDC_BROWSE_SELECT));
               break;
            }
         break;
      }

   return FALSE;
}
LRESULT CQuickSetupDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled){
	TRC(IDC_FTPSETTINGSBUTTON, "Настройки FTP");
	TRC(IDOK, "Продолжить");
	TRC(IDCANCEL, "Отмена");
	TRC(IDC_LOGINLABEL, "Логин:");
	TRC(IDC_PASSWORDLABEL, "Пароль:");
	TRC(IDC_SERVERLABEL, "На какой сервер будем загружать картинки?");
	TRC(IDC_AUTOSTARTUPCHECKBOX, "Запуск программы при старте Windows");
	TRC(IDC_CAPTUREPRINTSCREENCHECKBOX, "Перехватывать нажатия PrintScreen и Alt+PrintScreen");
	TRC(IDC_EXPLORERINTEGRATION, "Добавить пункт в контекстное меню проводника Windows");
	SetWindowText( APPNAME );
	CString titleText;
	titleText.Format(TR("%s - быстрая настройка"), APPNAME );
	SetDlgItemText(IDC_TITLE, titleText );

	CenterWindow();
	hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);
	SetIcon(hIcon, TRUE);
	hIconSmall = GuiTools::LoadSmallIcon(IDR_MAINFRAME);
	SetIcon(hIconSmall, FALSE);
	serverComboBox_.Attach( GetDlgItem( IDC_SERVERCOMBOBOX ) );

	if ( !Settings.IsPortable ) {
		SendDlgItemMessage( IDC_AUTOSTARTUPCHECKBOX, BM_SETCHECK, BST_CHECKED, 0);
		SendDlgItemMessage( IDC_CAPTUREPRINTSCREENCHECKBOX, BM_SETCHECK, BST_CHECKED, 0);
		SendDlgItemMessage( IDC_EXPLORERINTEGRATION, BM_SETCHECK, BST_CHECKED, 0);
	}
	LogoImage.SubclassWindow(GetDlgItem( IDC_STATICLOGO ) );
	LogoImage.SetWindowPos(0, 0,0, 48, 48, SWP_NOMOVE );
	LogoImage.LoadImage(0, 0, Settings.UseNewIcon ? IDR_ICONMAINNEW : IDR_PNG1, false, GetSysColor(COLOR_BTNFACE));

	HFONT font = GetFont();
	LOGFONT alf;

	bool ok = ::GetObject(font, sizeof(LOGFONT), &alf) == sizeof(LOGFONT);

	if(ok)
	{
		alf.lfWeight = FW_BOLD;

		NewFont=CreateFontIndirect(&alf);

		HDC dc = ::GetDC(0);
		alf.lfHeight  =  - MulDiv(11, GetDeviceCaps(dc, LOGPIXELSY), 72);
		ReleaseDC(dc);
		NewFont = CreateFontIndirect(&alf);
		SendDlgItemMessage(IDC_TITLE,WM_SETFONT,(WPARAM)(HFONT)NewFont,MAKELPARAM(false, 0));
	}
	
	comboBoxImageList_.Create(16,16,ILC_COLOR32 | ILC_MASK,0,6);

	//serverComboBox_.AddItem( _T("<") + CString(TR("Случайный сервер")) + _T(">"), -1, -1, 0, static_cast<LPARAM>( -1 ) );

	HICON hImageIcon = NULL, hFileIcon = NULL;
	int selectedIndex = 0;

	//CUploadEngineData *uploadEngine = _EngineList->byIndex( Settings.getServerID() );
	std::string selectedServerName = "directupload.net" ;
	for( int i = 0; i < _EngineList->count(); i++) {	
		CUploadEngineData * ue = _EngineList->byIndex( i ); 
		if ( ue->Type !=  CUploadEngineData::TypeImageServer && ue->Type !=  CUploadEngineData::TypeFileServer ) {
			continue;
		}
		HICON hImageIcon = _EngineList->getIconForServer(ue->Name);
		int nImageIndex = -1;
		if ( hImageIcon) {
			nImageIndex = comboBoxImageList_.AddIcon( hImageIcon);
		}
		char *serverName = new char[ue->Name.length() + 1];
		lstrcpyA( serverName, ue->Name.c_str() );
		int itemIndex = serverComboBox_.AddItem( Utf8ToWCstring( ue->Name ), nImageIndex, nImageIndex, 1, reinterpret_cast<LPARAM>( serverName ) );
		if ( ue->Name == selectedServerName ){
			selectedIndex = itemIndex;
		}
	}
	serverComboBox_.SetImageList( comboBoxImageList_ );
	serverComboBox_.SetCurSel( selectedIndex );

	doAuthCheckboxChanged();
	
	serverChanged();

	return 1;  
}
Example #13
0
//options page on miranda called
INT_PTR CALLBACK DlgProcConnectionNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND hwndList;
	switch (msg) {
	case WM_INITDIALOG://initialize dialog, so set properties from db.
	{
		LVCOLUMN lvc = { 0 };
		LVITEM lvI = { 0 };
		TCHAR buff[256];
		bOptionsOpen = TRUE;
		TranslateDialogDefault(hwndDlg);//translate miranda function
#ifdef _WIN64
		mir_sntprintf(buff,_countof(buff),_T("%d.%d.%d.%d/64"), HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version)));
#else
		mir_sntprintf(buff, _T("%d.%d.%d.%d/32"), HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version)));
#endif
		SetDlgItemText(hwndDlg, IDC_VERSION, buff);
		LoadSettings();
		//connExceptionsTmp=LoadSettingsConnections();
		SetDlgItemInt(hwndDlg, IDC_INTERVAL, settingInterval, FALSE);
		SetDlgItemInt(hwndDlg, IDC_INTERVAL1, settingInterval1, TRUE);
		CheckDlgButton(hwndDlg, IDC_SETCOLOURS, settingSetColours ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, IDC_RESOLVEIP, settingResolveIp ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, ID_CHK_DEFAULTACTION, settingDefaultAction ? BST_CHECKED : BST_UNCHECKED);

		SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingBgColor);
		SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingFgColor);
		if (!settingSetColours) {
			HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR);
			CheckDlgButton(hwndDlg, IDC_SETCOLOURS, BST_UNCHECKED);
			EnableWindow(hwnd, FALSE);
			hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR);
			EnableWindow(hwnd, FALSE);
		}
		SendDlgItemMessage(hwndDlg, ID_ADD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON6), IMAGE_ICON, 16, 16, 0));
		SendDlgItemMessage(hwndDlg, ID_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON3), IMAGE_ICON, 16, 16, 0));
		SendDlgItemMessage(hwndDlg, ID_DOWN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON4), IMAGE_ICON, 16, 16, 0));
		SendDlgItemMessage(hwndDlg, ID_UP, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON5), IMAGE_ICON, 16, 16, 0));
		// initialise and fill listbox
		hwndList = GetDlgItem(hwndDlg, IDC_STATUS);
		ListView_DeleteAllItems(hwndList);
		SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
		// Initialize the LVCOLUMN structure.
		// The mask specifies that the format, width, text, and
		// subitem members of the structure are valid. 
		lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
		lvc.fmt = LVCFMT_LEFT;
		lvc.iSubItem = 0;
		lvc.pszText = TranslateT("Status");
		lvc.cx = 120;     // width of column in pixels
		ListView_InsertColumn(hwndList, 0, &lvc);
		// Some code to create the list-view control.
		// Initialize LVITEM members that are common to all
		// items. 
		lvI.mask = LVIF_TEXT;
		for (int i = 0; i < STATUS_COUNT; i++) {
			lvI.pszText = pcli->pfnGetStatusModeDescription(ID_STATUS_ONLINE + i, 0);
			lvI.iItem = i;
			ListView_InsertItem(hwndList, &lvI);
			ListView_SetCheckState(hwndList, i, settingStatus[i]);
		}

		connExceptionsTmp = LoadSettingsConnections();
		hwndList = GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS);
		SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);

		lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
		lvc.fmt = LVCFMT_LEFT;
		lvc.iSubItem = 0;
		lvc.cx = 120;     // width of column in pixels
		lvc.pszText = TranslateT("Application");
		ListView_InsertColumn(hwndList, 1, &lvc);
		lvc.pszText = TranslateT("Internal socket");
		ListView_InsertColumn(hwndList, 2, &lvc);
		lvc.pszText = TranslateT("External socket");
		ListView_InsertColumn(hwndList, 3, &lvc);
		lvc.pszText = TranslateT("Action");
		lvc.cx = 50;
		ListView_InsertColumn(hwndList, 4, &lvc);

		//fill exceptions list
		fillExceptionsListView(hwndDlg);
	}
	break;

	case WM_COMMAND://user changed something, so get changes to variables
		PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
		switch (LOWORD(wParam)) {
		case IDC_INTERVAL: settingInterval = GetDlgItemInt(hwndDlg, IDC_INTERVAL, NULL, FALSE); break;
		case IDC_INTERVAL1: settingInterval1 = GetDlgItemInt(hwndDlg, IDC_INTERVAL1, NULL, TRUE); break;
		case IDC_RESOLVEIP: settingResolveIp = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_RESOLVEIP); break;
		case ID_CHK_DEFAULTACTION: settingDefaultAction = (BYTE)IsDlgButtonChecked(hwndDlg, ID_CHK_DEFAULTACTION); break;
		case ID_ADD:
		{
			struct CONNECTION *cur = (struct CONNECTION *)mir_alloc(sizeof(struct CONNECTION));
			memset(cur, 0, sizeof(struct CONNECTION));
			cur->intExtPort = -1;
			cur->intIntPort = -1;
			cur->Pid = 0;
			cur->PName[0] = '*';
			cur->strExtIp[0] = '*';
			cur->strIntIp[0] = '*';

			if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, FilterEditProc, (LPARAM)cur) == IDCANCEL) {
				mir_free(cur);
				cur = NULL;
			}
			else {
				cur->next = connExceptionsTmp;
				connExceptionsTmp = cur;
			}

			fillExceptionsListView(hwndDlg);
			ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), 0, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
			SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
		}
		break;

		case ID_DELETE:
		{
			int pos, pos1;
			struct CONNECTION *cur = connExceptionsTmp, *pre = NULL;

			pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
			if (pos == -1)break;
			pos1 = pos;
			while (pos--)
			{
				pre = cur;
				cur = cur->next;
			}
			if (pre == NULL)
				connExceptionsTmp = connExceptionsTmp->next;
			else
				(pre)->next = cur->next;
			mir_free(cur);
			fillExceptionsListView(hwndDlg);
			ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
			SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
			break;
		}
		case ID_UP:
		{
			int pos, pos1;
			struct CONNECTION *cur = NULL, *pre = NULL, *prepre = NULL;

			cur = connExceptionsTmp;

			pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
			if (pos == -1)break;
			pos1 = pos;
			while (pos--)
			{
				prepre = pre;
				pre = cur;
				cur = cur->next;
			}
			if (prepre != NULL)
			{
				pre->next = cur->next;
				cur->next = pre;
				prepre->next = cur;
			}
			else if (pre != NULL)
			{
				pre->next = cur->next;
				cur->next = pre;
				connExceptionsTmp = cur;
			}
			fillExceptionsListView(hwndDlg);
			ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1 - 1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
			SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
			break;
		}
		case ID_DOWN:
		{
			int pos, pos1;
			struct CONNECTION *cur = NULL, *pre = NULL;

			cur = connExceptionsTmp;

			pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
			if (pos == -1)break;
			pos1 = pos;
			while (pos--)
			{
				pre = cur;
				cur = cur->next;
			}
			if (cur == connExceptionsTmp&&cur->next != NULL)
			{
				connExceptionsTmp = cur->next;
				cur->next = cur->next->next;
				connExceptionsTmp->next = cur;
			}
			else if (cur->next != NULL)
			{
				struct CONNECTION *tmp = cur->next->next;
				pre->next = cur->next;
				cur->next->next = cur;
				cur->next = tmp;
			}
			fillExceptionsListView(hwndDlg);
			ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1 + 1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
			SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
			break;
		}
		case IDC_SETCOLOURS:
		{
			HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR);
			settingSetColours = IsDlgButtonChecked(hwndDlg, IDC_SETCOLOURS);
			EnableWindow(hwnd, settingSetColours);
			hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR);
			EnableWindow(hwnd, settingSetColours);
			break;
		}
		case IDC_BGCOLOR: settingBgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0); break;
		case IDC_FGCOLOR: settingFgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_GETCOLOUR, 0, 0); break;

		}
		break;

	case WM_NOTIFY://apply changes so write it to db
		switch (((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_RESET:
				LoadSettings();
				deleteConnectionsTable(connExceptionsTmp);
				connExceptionsTmp = LoadSettingsConnections();
				return TRUE;

			case PSN_APPLY:
				db_set_dw(NULL, PLUGINNAME, "Interval", settingInterval);
				db_set_dw(NULL, PLUGINNAME, "PopupInterval", settingInterval1);
				db_set_b(NULL, PLUGINNAME, "PopupSetColours", settingSetColours);
				db_set_dw(NULL, PLUGINNAME, "PopupBgColor", (DWORD)settingBgColor);
				db_set_dw(NULL, PLUGINNAME, "PopupFgColor", (DWORD)settingFgColor);
				db_set_b(NULL, PLUGINNAME, "ResolveIp", settingResolveIp);
				db_set_b(NULL, PLUGINNAME, "FilterDefaultAction", settingDefaultAction);

				for (int i = 0; i < STATUS_COUNT; i++) {
					char buff[128];
					mir_snprintf(buff, "Status%d", i);
					settingStatus[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_STATUS), i) ? TRUE : FALSE);
					db_set_b(0, PLUGINNAME, buff, settingStatus[i] ? 1 : 0);
				}
				if (WAIT_OBJECT_0 == WaitForSingleObject(hExceptionsMutex, 100)) {
					deleteConnectionsTable(connExceptions);
					saveSettingsConnections(connExceptionsTmp);
					connExceptions = connExceptionsTmp;
					connExceptionsTmp = LoadSettingsConnections();
					ReleaseMutex(hExceptionsMutex);
				}
				return TRUE;
			}
			break;
		}

		if (GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS) == ((LPNMHDR)lParam)->hwndFrom) {
			switch (((LPNMHDR)lParam)->code) {
			case NM_DBLCLK:
			{
				int pos, pos1;
				struct CONNECTION *cur = NULL;

				cur = connExceptionsTmp;

				pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
				if (pos == -1)break;
				pos1 = pos;
				while (pos--)
				{
					cur = cur->next;
				}
				DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, FilterEditProc, (LPARAM)cur);
				fillExceptionsListView(hwndDlg);
				ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
				SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
				break;
			}
			}
		}

		if (GetDlgItem(hwndDlg, IDC_STATUS) == ((LPNMHDR)lParam)->hwndFrom) {
			switch (((LPNMHDR)lParam)->code) {
			case LVN_ITEMCHANGED:
				NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
				if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK)
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;
			}
		}
		break;

	case WM_DESTROY:
		bOptionsOpen = FALSE;
		deleteConnectionsTable(connExceptionsTmp);
		connExceptionsTmp = NULL;
		return TRUE;
	}
	return 0;
}
Example #14
0
//filter editor dialog box procedure opened modally from options dialog
static INT_PTR CALLBACK FilterEditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_INITDIALOG:
	{
		struct CONNECTION *conn = (struct CONNECTION*)lParam;
		TranslateDialogDefault(hWnd);
		connCurrentEditModal = conn;
		SetDlgItemText(hWnd, ID_TEXT_NAME, conn->PName);
		SetDlgItemText(hWnd, ID_TXT_LOCAL_IP, conn->strIntIp);
		SetDlgItemText(hWnd, ID_TXT_REMOTE_IP, conn->strExtIp);

		if (conn->intIntPort == -1)
			SetDlgItemText(hWnd, ID_TXT_LOCAL_PORT, _T("*"));
		else
			SetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT, conn->intIntPort, FALSE);

		if (conn->intExtPort == -1)
			SetDlgItemText(hWnd, ID_TXT_REMOTE_PORT, _T("*"));
		else
			SetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT, conn->intExtPort, FALSE);

		SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Always show popup"));
		SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Never show popup"));
		SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_SETCURSEL, conn->Pid == 0 ? 1 : 0, 0);
		return TRUE;
	}
	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case ID_OK:
		{
			TCHAR tmpPort[6];
			GetDlgItemText(hWnd, ID_TXT_LOCAL_PORT, tmpPort, _countof(tmpPort));
			if (tmpPort[0] == '*')
				connCurrentEditModal->intIntPort = -1;
			else
				connCurrentEditModal->intIntPort = GetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT, NULL, FALSE);
			GetDlgItemText(hWnd, ID_TXT_REMOTE_PORT, tmpPort, _countof(tmpPort));
			if (tmpPort[0] == '*')
				connCurrentEditModal->intExtPort = -1;
			else
				connCurrentEditModal->intExtPort = GetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT, NULL, FALSE);

			GetDlgItemText(hWnd, ID_TXT_LOCAL_IP, connCurrentEditModal->strIntIp, _countof(connCurrentEditModal->strIntIp));
			GetDlgItemText(hWnd, ID_TXT_REMOTE_IP, connCurrentEditModal->strExtIp, _countof(connCurrentEditModal->strExtIp));
			GetDlgItemText(hWnd, ID_TEXT_NAME, connCurrentEditModal->PName, _countof(connCurrentEditModal->PName));

			connCurrentEditModal->Pid = !(BOOL)SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_GETCURSEL, 0, 0);

			connCurrentEditModal = NULL;
			EndDialog(hWnd, IDOK);
			return TRUE;
		}
		case ID_CANCEL:
			connCurrentEditModal = NULL;
			EndDialog(hWnd, IDCANCEL);
			return TRUE;
		}
		return FALSE;
		break;
	case WM_CLOSE:
	{
		connCurrentEditModal = NULL;
		EndDialog(hWnd, IDCANCEL);
		break;
	}
	}
	return FALSE;
}
Example #15
0
BOOL TSetupSheet::SetData()
{
	if (resId == MAIN_SHEET) {
		if (sv) {
			sv->bufSize			= cfg->bufSize;
			sv->estimateMode	= cfg->estimateMode;
			sv->ignoreErr		= cfg->ignoreErr;
			sv->enableVerify	= cfg->enableVerify;
			sv->enableAcl		= cfg->enableAcl;
			sv->enableStream	= cfg->enableStream;
			sv->speedLevel		= cfg->speedLevel;
			sv->isExtendFilter	= cfg->isExtendFilter;
			sv->enableOwdel		= cfg->enableOwdel;
		}
		SetDlgItemInt(BUFSIZE_EDIT, cfg->bufSize);
		CheckDlgButton(ESTIMATE_CHECK, cfg->estimateMode);
		CheckDlgButton(IGNORE_CHECK, cfg->ignoreErr);
		CheckDlgButton(VERIFY_CHECK, cfg->enableVerify);
		CheckDlgButton(ACL_CHECK, cfg->enableAcl);
		CheckDlgButton(STREAM_CHECK, cfg->enableStream);
		SendDlgItemMessage(SPEED_SLIDER, TBM_SETRANGE, 0, MAKELONG(SPEED_SUSPEND, SPEED_FULL));
		SetSpeedLevelLabel(this, cfg->speedLevel);
		CheckDlgButton(EXTENDFILTER_CHECK, cfg->isExtendFilter);
		CheckDlgButton(OWDEL_CHECK, cfg->enableOwdel);
	}
	else if (resId == IO_SHEET) {
		SetDlgItemInt(MAXTRANS_EDIT, cfg->maxTransSize);
		SetDlgItemInt(MAXOVL_EDIT, cfg->maxOvlNum);
		if (cfg->minSectorSize == 0 || cfg->minSectorSize == 4096) {
			CheckDlgButton(SECTOR4096_CHECK, cfg->minSectorSize == 4096);
		} else {
			::EnableWindow(GetDlgItem(SECTOR4096_CHECK), FALSE);
		}
		CheckDlgButton(READOSBUF_CHECK, cfg->isReadOsBuf);
		SetDlgItemInt(NONBUFMINNTFS_EDIT, cfg->nbMinSizeNtfs);
		SetDlgItemInt(NONBUFMINFAT_EDIT, cfg->nbMinSizeFat);
	}
	else if (resId == PHYSDRV_SHEET) {
		SetDlgItemText(DRIVEMAP_EDIT, cfg->driveMap);
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_ADDSTRING, 0, (LPARAM)LoadStr(IDS_NETDRV_UNC));
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_ADDSTRING, 0, (LPARAM)LoadStr(IDS_NETDRV_SVR));
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_ADDSTRING, 0, (LPARAM)LoadStr(IDS_NETDRV_ALL));
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_SETCURSEL, cfg->netDrvMode, 0);
	}
	else if (resId == PARALLEL_SHEET) {
		SetDlgItemInt(MAXRUN_EDIT, cfg->maxRunNum);
		CheckDlgButton(FORCESTART_CHECK, cfg->forceStart);
	}
	else if (resId == COPYOPT_SHEET) {
		CheckDlgButton(SAMEDIR_RENAME_CHECK, cfg->isSameDirRename);
		CheckDlgButton(EMPTYDIR_CHECK, cfg->skipEmptyDir);
		CheckDlgButton(REPARSE_CHECK, cfg->isReparse);
		::EnableWindow(GetDlgItem(REPARSE_CHECK), TRUE);
		CheckDlgButton(MOVEATTR_CHECK, cfg->enableMoveAttr);
		CheckDlgButton(SERIALMOVE_CHECK, cfg->serialMove);
		CheckDlgButton(SERIALVERIFYMOVE_CHECK, cfg->serialVerifyMove);
		SendDlgItemMessage(HASH_COMBO, CB_ADDSTRING, 0, (LPARAM)"MD5");
		SendDlgItemMessage(HASH_COMBO, CB_ADDSTRING, 0, (LPARAM)"SHA-1");
		SendDlgItemMessage(HASH_COMBO, CB_ADDSTRING, 0, (LPARAM)"SHA-256");
		SendDlgItemMessage(HASH_COMBO, CB_SETCURSEL, cfg->hashMode, 0);
		SetDlgItemInt(TIMEGRACE_EDIT, cfg->timeDiffGrace);
	}
	else if (resId == DEL_SHEET) {
		CheckDlgButton(NSA_CHECK, cfg->enableNSA);
		CheckDlgButton(DELDIR_CHECK, cfg->delDirWithFilter);
	}
	else if (resId == LOG_SHEET) {
		SetDlgItemInt(HISTORY_EDIT, cfg->maxHistoryNext);
		CheckDlgButton(ERRLOG_CHECK, cfg->isErrLog);
		CheckDlgButton(UTF8LOG_CHECK, cfg->isUtf8Log);
		::EnableWindow(GetDlgItem(UTF8LOG_CHECK), TRUE);
		CheckDlgButton(FILELOG_CHECK, cfg->fileLogMode);
		CheckDlgButton(TIMESTAMP_CHECK, (cfg->fileLogFlags & FastCopy::FILELOG_TIMESTAMP) ?
			TRUE : FALSE);
		CheckDlgButton(FILESIZE_CHECK,  (cfg->fileLogFlags & FastCopy::FILELOG_FILESIZE)  ?
			TRUE : FALSE);
		CheckDlgButton(ACLERRLOG_CHECK, cfg->aclErrLog);
		::EnableWindow(GetDlgItem(ACLERRLOG_CHECK), TRUE);
		CheckDlgButton(STREAMERRLOG_CHECK, cfg->streamErrLog);
		::EnableWindow(GetDlgItem(STREAMERRLOG_CHECK), TRUE);
	}
	else if (resId == MISC_SHEET) {
		CheckDlgButton(EXECCONFIRM_CHECK, cfg->execConfirm);
		CheckDlgButton(TASKBAR_CHECK, cfg->taskbarMode);
		CheckDlgButton(FINISH_CHECK, (cfg->finishNotify & 1));
		CheckDlgButton(SPAN1_RADIO + cfg->infoSpan, 1);
		CheckDlgButton(PREVENTSLEEP_CHECK, cfg->preventSleep);

		if ((cfg->lcid != -1 || GetSystemDefaultLCID() != 0x409)) { // == 0x411 改成 != 0x409 让所有语言都可以切换到英文
			::ShowWindow(GetDlgItem(LCID_CHECK), SW_SHOW);
			::EnableWindow(GetDlgItem(LCID_CHECK), TRUE);
			CheckDlgButton(LCID_CHECK, cfg->lcid == -1 || cfg->lcid != 0x409 ? FALSE : TRUE);
		}
	}
	return	TRUE;
}
Example #16
0
/*
* PipeQueryInfo
*
* Purpose:
*
* Query basic info about pipe.
*
*/
VOID PipeQueryInfo(
    PROP_OBJECT_INFO *Context,
    HWND hwndDlg
)
{
    LPWSTR                      lpType;
    HANDLE                      hPipe;
    NTSTATUS                    status;
    WCHAR                       szBuffer[MAX_PATH];
    IO_STATUS_BLOCK             iost;
    FILE_PIPE_LOCAL_INFORMATION fpli;

    //validate context
    if (Context == NULL) {
        SetLastError(ERROR_NOT_ENOUGH_MEMORY);
        PipeDisplayError(hwndDlg);
        return;
    }
    if (
        (Context->lpObjectName == NULL) ||
        (Context->lpCurrentObjectPath == NULL)
        )
    {
        SetLastError(ERROR_OBJECT_NOT_FOUND);
        PipeDisplayError(hwndDlg);
        return;
    }

    SetDlgItemText(hwndDlg, ID_PIPE_FULLPATH, Context->lpCurrentObjectPath);

    //open pipe
    hPipe = NULL;
    if (!PipeOpenObjectMethod(Context, &hPipe, GENERIC_READ)) {
        //on error display last win32 error
        PipeDisplayError(hwndDlg);
        return;
    }

    RtlSecureZeroMemory(&fpli, sizeof(fpli));
    status = NtQueryInformationFile(hPipe, &iost, &fpli, sizeof(fpli), FilePipeLocalInformation);
    if (NT_SUCCESS(status)) {

        //Type
        lpType = TEXT("?");
        switch (fpli.NamedPipeType) {
        case FILE_PIPE_BYTE_STREAM_TYPE:
            lpType = TEXT("Byte stream");
            break;
        case FILE_PIPE_MESSAGE_TYPE:
            lpType = TEXT("Message");
            break;
        }
        SetDlgItemText(hwndDlg, ID_PIPE_TYPEMODE, lpType);

        //AccessMode
        lpType = TEXT("?");
        switch (fpli.NamedPipeConfiguration) {
        case FILE_PIPE_INBOUND:
            lpType = TEXT("Inbound");
            break;
        case FILE_PIPE_OUTBOUND:
            lpType = TEXT("Outbound");
            break;
        case FILE_PIPE_FULL_DUPLEX:
            lpType = TEXT("Duplex");
            break;
        }
        SetDlgItemText(hwndDlg, ID_PIPE_ACCESSMODE, lpType);

        //CurrentInstances
        RtlSecureZeroMemory(&szBuffer, sizeof(szBuffer));
        ultostr(fpli.CurrentInstances, szBuffer);
        SetDlgItemText(hwndDlg, ID_PIPE_CURINSTANCES, szBuffer);

        //MaximumInstances
        RtlSecureZeroMemory(&szBuffer, sizeof(szBuffer));
        if (fpli.MaximumInstances == MAXDWORD) {
            _strcpy(szBuffer, TEXT("Unlimited"));
        }
        else {
            ultostr(fpli.MaximumInstances, szBuffer);
        }
        SetDlgItemText(hwndDlg, ID_PIPE_MAXINSTANCES, szBuffer);

        //InboundQuota
        RtlSecureZeroMemory(&szBuffer, sizeof(szBuffer));
        ultostr(fpli.InboundQuota, szBuffer);
        SetDlgItemText(hwndDlg, ID_PIPE_INBUFFER, szBuffer);

        //OutboundQuota
        RtlSecureZeroMemory(&szBuffer, sizeof(szBuffer));
        ultostr(fpli.OutboundQuota, szBuffer);
        SetDlgItemText(hwndDlg, ID_PIPE_OUTBUFFER, szBuffer);

        //WriteQuotaAvailable
        RtlSecureZeroMemory(&szBuffer, sizeof(szBuffer));
        ultostr(fpli.WriteQuotaAvailable, szBuffer);
        SetDlgItemText(hwndDlg, ID_PIPE_WRITEQUOTAAVAIL, szBuffer);
    }
    else {
        //show detail on query error
        SetLastError(RtlNtStatusToDosError(status));
        PipeDisplayError(hwndDlg);
    }
    NtClose(hPipe);
}
Example #17
0
static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) 
{ 
    BOOL fError; 
 
    switch(message) 
    { 
		case WM_INITDIALOG:
			SET_CHECK(OUT_Lossless_Radio, g_lossless);
			SET_CHECK(OUT_Lossy_Radio, !g_lossless);

			SendMessage(GET_ITEM(OUT_Quality_Slider),(UINT)TBM_SETRANGEMIN, (WPARAM)(BOOL)FALSE, (LPARAM)0);
			SendMessage(GET_ITEM(OUT_Quality_Slider),(UINT)TBM_SETRANGEMAX, (WPARAM)(BOOL)FALSE, (LPARAM)100);
			SendMessage(GET_ITEM(OUT_Quality_Slider),(UINT)TBM_SETPOS, (WPARAM)(BOOL)TRUE, (LPARAM)g_quality);

			if(!g_have_transparency)
			{
				ENABLE_ITEM(OUT_Alpha_Radio_Transparency, FALSE);

				if(g_alpha == DIALOG_ALPHA_TRANSPARENCY)
				{
					g_alpha = (g_alpha_name != NULL ? DIALOG_ALPHA_CHANNEL : DIALOG_ALPHA_NONE);
				}
			}

			if(g_alpha_name == NULL)
			{
				ENABLE_ITEM(OUT_Alpha_Radio_Channel, FALSE);

				if(g_alpha == DIALOG_ALPHA_CHANNEL)
				{
					g_alpha = (g_have_transparency ? DIALOG_ALPHA_TRANSPARENCY : DIALOG_ALPHA_NONE);
				}
			}
			else
			{
				SetDlgItemText(hwndDlg, OUT_Alpha_Radio_Channel, g_alpha_name);
			}

			SET_CHECK( (g_alpha == DIALOG_ALPHA_NONE ? OUT_Alpha_Radio_None :
						g_alpha == DIALOG_ALPHA_TRANSPARENCY ? OUT_Alpha_Radio_Transparency :
						g_alpha == DIALOG_ALPHA_CHANNEL ? OUT_Alpha_Radio_Channel :
						OUT_Alpha_Radio_None), TRUE);

			SET_CHECK(OUT_Alpha_Cleanup_Check, g_alpha_cleanup);
			SET_CHECK(OUT_Lossy_Alpha_Check, g_lossy_alpha);
			SET_CHECK(OUT_Save_Metadata_Check, g_save_metadata);

			TrackLossless(hwndDlg);
			TrackSlider(hwndDlg);
			TrackAlpha(hwndDlg);

			return TRUE;
 
		case WM_NOTIFY:
			switch(LOWORD(wParam))
			{
				case OUT_Quality_Slider:
					TrackSlider(hwndDlg);
				return TRUE;
			}
		return FALSE;

        case WM_COMMAND: 
			g_item_clicked = LOWORD(wParam);

            switch(g_item_clicked)
            { 
                case OUT_OK: 
				case OUT_Cancel:  // do the same thing, but g_item_clicked will be different
					g_lossless = GET_CHECK(OUT_Lossless_Radio);
					g_quality = SendMessage(GET_ITEM(OUT_Quality_Slider), TBM_GETPOS, (WPARAM)0, (LPARAM)0 );

					g_alpha =	GET_CHECK(OUT_Alpha_Radio_None) ? DIALOG_ALPHA_NONE :
								GET_CHECK(OUT_Alpha_Radio_Transparency) ? DIALOG_ALPHA_TRANSPARENCY :
								GET_CHECK(OUT_Alpha_Radio_Channel) ? DIALOG_ALPHA_CHANNEL :
								DIALOG_ALPHA_TRANSPARENCY;

					g_alpha_cleanup = GET_CHECK(OUT_Alpha_Cleanup_Check);
					g_lossy_alpha = GET_CHECK(OUT_Lossy_Alpha_Check);
					g_save_metadata = GET_CHECK(OUT_Save_Metadata_Check);

					EndDialog(hwndDlg, 0);
					return TRUE;


				case OUT_Lossless_Radio:
				case OUT_Lossy_Radio:
					TrackLossless(hwndDlg);
					return TRUE;

				case OUT_Alpha_Radio_None:
				case OUT_Alpha_Radio_Transparency:
				case OUT_Alpha_Radio_Channel:
					TrackAlpha(hwndDlg);

				case OUT_Quality_Field:
					TrackField(hwndDlg);
					return TRUE;
            } 
    } 
    return FALSE; 
} 
Example #18
0
//-----------------------------------------------------------------------------
// Name: GreetingDlgProc()
// Desc: Handles dialog messages
//-----------------------------------------------------------------------------
INT_PTR CALLBACK GreetingDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg ) 
    {
        case WM_INITDIALOG:
            {
                g_hDlg = hDlg;

                // Load and set the icon
                HICON hIcon = LoadIcon( g_hInst, MAKEINTRESOURCE( IDI_MAIN ) );
                SendMessage( hDlg, WM_SETICON, ICON_BIG,   (LPARAM) hIcon );  // Set big icon
                SendMessage( hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon );  // Set small icon

                // Display local player's name
                SetDlgItemText( hDlg, IDC_PLAYER_NAME, g_strLocalPlayerName );

                if( g_pNetConnectWizard->IsHostPlayer() )
                    SetWindowText( hDlg, TEXT("StagedPeer (Host)") );
                else
                    SetWindowText( hDlg, TEXT("StagedPeer") );

                PostMessage( hDlg, WM_APP_UPDATE_STATS, 0, 0 );
            }
            break;

        case WM_APP_UPDATE_STATS:
        {
            // Update the number of players in the game
            TCHAR strNumberPlayers[32];

            wsprintf( strNumberPlayers, TEXT("%d"), g_lNumberOfActivePlayers );
            SetDlgItemText( hDlg, IDC_NUM_PLAYERS, strNumberPlayers );
            break;
        }

        case WM_APP_DISPLAY_WAVE:
        {
            HRESULT          hr;
            DPNID            dpnidPlayer = (DPNID) wParam;
            APP_PLAYER_INFO* pPlayerInfo = NULL;

            PLAYER_LOCK(); // enter player context CS

            // Get the player context accosicated with this DPNID
            hr = g_pDP->GetPlayerContext( dpnidPlayer, 
                                          (LPVOID* const) &pPlayerInfo,
										  0);

            PLAYER_ADDREF( pPlayerInfo ); // addref player, since we are using it now
            PLAYER_UNLOCK(); // leave player context CS

            if( FAILED(hr) || pPlayerInfo == NULL )
            {
                // The player who sent this may have gone away before this 
                // message was handled, so just ignore it
                break;
            }
            
            // Make wave message and display it.
            TCHAR szWaveMessage[MAX_PATH];
            wsprintf( szWaveMessage, TEXT("%s just waved at you, %s!\r\n"), 
                      pPlayerInfo->strPlayerName, g_strLocalPlayerName );

            PLAYER_LOCK();
            PLAYER_RELEASE( pPlayerInfo );  // Release player and cleanup if needed
            PLAYER_UNLOCK();

            AppendTextToEditControl( hDlg, szWaveMessage );
            break;
        }

        case WM_COMMAND:
            switch( LOWORD(wParam) )
            {
                case IDC_WAVE:
                    if( FAILED( g_hrDialog = WaveToAllPlayers() ) )
                    {
                        DXTRACE_ERR( TEXT("WaveToAllPlayers"), g_hrDialog );
                        EndDialog( hDlg, 0 );
                    }

                    return TRUE;

                case IDCANCEL:
                    EndDialog( hDlg, 0 );
                    return TRUE;
            }
            break;
    }

    return FALSE; // Didn't handle message
}
BOOL CALLBACK DialogFloppyDump(
						  HWND  hwndDlg,	// handle of dialog box
						  UINT  message,	// message
						  WPARAM  wParam,	// first message parameter
						  LPARAM  lParam 	// second message parameter
						  )
{
	static char nbinstance=0;
	char tempstr[128];
	int wmId, wmEvent;
	DWORD sit;

	wmId    = LOWORD(wParam); 
	wmEvent = HIWORD(wParam); 
	
	switch (message) 
	{
		
	case WM_COMMAND:
		
		switch (wmEvent)
		{
			case BN_CLICKED:
			
			
			break;	
		}

		switch (wmId)
		{

			case IDOK:
				if(!fdparams.status)
				{
					//KillTimer(hwndDlg,34);
					nbinstance=0;
					DestroyWindow(hwndDlg);
				}
			break;

			
			case IDLOAD_READDISK:
				if(!fdparams.status)
				{
					fdparams.floppydisk=(FLOPPY*)malloc(sizeof(FLOPPY));
					memset(fdparams.floppydisk,0,sizeof(FLOPPY));

					fdparams.windowshwd=hwndDlg;
					fdparams.flopemu=flopemu;
					fdparams.double_step=1;
					fdparams.number_of_side=1;
					fdparams.number_of_track=GetDlgItemInt(hwndDlg,IDC_NUMBEROFTRACK_DUMP,NULL,0);
					fdparams.status=1;

					if(SendDlgItemMessage(hwndDlg,IDC_RADIO1,BM_GETCHECK,0,0))
						fdparams.drive=0;
					if(SendDlgItemMessage(hwndDlg,IDC_RADIO2,BM_GETCHECK,0,0))
						fdparams.drive=1;

					if(SendDlgItemMessage(hwndDlg,IDC_DOUBLESIDE_DUMP,BM_GETCHECK,0,0))
					{
						fdparams.number_of_side=2;
					}

					if(SendDlgItemMessage(hwndDlg,IDC_DOUBLESTEP_DUMP,BM_GETCHECK,0,0))
					{
						fdparams.double_step=2;
					}

					sprintf(tempstr,"%d Sector(s) Read, %d bytes, %d Bad sector(s)",0,0,0);
					SetDlgItemText(hwndDlg,IDC_EDIT2,tempstr);

					CreateThread(NULL,0,&DumpThreadProc,&fdparams,0,&sit);

				}
			break;

			
			default:;
			break;

		}
		
		
		break;
		
		
		case WM_INITDIALOG:
			if(nbinstance!=0)
			{
				DestroyWindow(hwndDlg);
			}
			else
			{

				SendDlgItemMessage(hwndDlg,IDC_DOUBLESIDE_DUMP,BM_SETCHECK,BST_CHECKED,0);
				SendDlgItemMessage(hwndDlg,IDC_RADIO1,BM_SETCHECK,BST_CHECKED,0);
				SetDlgItemInt(hwndDlg,IDC_NUMBEROFTRACK_DUMP,80,0);
				memset(&fdparams,0,sizeof(fdparams));
				sprintf(tempstr,"%d Sector(s) Read, %d bytes, %d Bad sector(s)",0,0,0);
				SetDlgItemText(hwndDlg,IDC_EDIT2,tempstr);
			}
			//SetTimer(hwndDlg,34,500,NULL);
			break;
			
		case WM_CLOSE:
			if(!fdparams.status)
			{
				//KillTimer(hwndDlg,34);
				nbinstance=0;
				DestroyWindow(hwndDlg);
			}
			break;
			
			
		case WM_TIMER:
			break;
			
		default:
			return FALSE;
			
	}
	
	return TRUE;
}
Example #20
0
void Filesets_General_OnEndTask_InitDialog (HWND hDlg, LPTASKPACKET ptp, LPIDENT lpi)
{
   LPTSTR pszText;

   TCHAR szUnknown[ cchRESOURCE ];
   GetString (szUnknown, IDS_UNKNOWN);

   if (!ptp->rc)
      {
      SetDlgItemText (hDlg, IDC_SET_CREATEDATE, szUnknown);
      SetDlgItemText (hDlg, IDC_SET_UPDATEDATE, szUnknown);
      SetDlgItemText (hDlg, IDC_SET_ACCESSDATE, szUnknown);
      SetDlgItemText (hDlg, IDC_SET_BACKUPDATE, szUnknown);
      SetDlgItemText (hDlg, IDC_SET_USAGE, szUnknown);
      SetDlgItemText (hDlg, IDC_SET_STATUS, szUnknown);
      SetDlgItemText (hDlg, IDC_SET_FILES, szUnknown);

      TCHAR szSvrName[ cchNAME ];
      TCHAR szAggName[ cchNAME ];
      TCHAR szSetName[ cchNAME ];
      lpi->GetServerName (szSvrName);
      lpi->GetAggregateName (szAggName);
      lpi->GetFilesetName (szSetName);
      ErrorDialog (ptp->status, IDS_ERROR_REFRESH_FILESET_STATUS, TEXT("%s%s%s"), szSvrName, szAggName, szSetName);
      }
   else
      {
      TCHAR szText[ cchRESOURCE ];

      EnableWindow (GetDlgItem (hDlg, IDC_SET_LOCK), TRUE);
      EnableWindow (GetDlgItem (hDlg, IDC_SET_UNLOCK), TRUE);
      EnableWindow (GetDlgItem (hDlg, IDC_SET_QUOTA), TRUE);
      EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN), TRUE);
      EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_DEF), TRUE);
      EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL), TRUE);
      EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_PERCENT), TRUE);
      EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_DESC), TRUE);

      if (!FormatTime (szText, TEXT("%s"), &TASKDATA(ptp)->fs.timeCreation))
         SetDlgItemText (hDlg, IDC_SET_CREATEDATE, szUnknown);
      else
         SetDlgItemText (hDlg, IDC_SET_CREATEDATE, szText);

      if (!FormatTime (szText, TEXT("%s"), &TASKDATA(ptp)->fs.timeLastUpdate))
         SetDlgItemText (hDlg, IDC_SET_UPDATEDATE, szUnknown);
      else
         SetDlgItemText (hDlg, IDC_SET_UPDATEDATE, szText);

      if (!FormatTime (szText, TEXT("%s"), &TASKDATA(ptp)->fs.timeLastAccess))
         SetDlgItemText (hDlg, IDC_SET_ACCESSDATE, szUnknown);
      else
         SetDlgItemText (hDlg, IDC_SET_ACCESSDATE, szText);

      if (!FormatTime (szText, TEXT("%s"), &TASKDATA(ptp)->fs.timeLastBackup))
         SetDlgItemText (hDlg, IDC_SET_BACKUPDATE, szUnknown);
      else
         SetDlgItemText (hDlg, IDC_SET_BACKUPDATE, szText);

      wsprintf (szText, TEXT("%lu"), TASKDATA(ptp)->fs.nFiles);
      SetDlgItemText (hDlg, IDC_SET_FILES, szText);

      size_t nAlerts = Alert_GetCount (lpi);
      if (nAlerts == 1)
         {
         GetString (szText, IDS_SETSTATUS_1ALERT);
         SetDlgItemText (hDlg, IDC_SET_STATUS, szText);
         }
      else if (nAlerts > 1)
         {
         pszText = FormatString (IDS_SETSTATUS_2ALERT, TEXT("%lu"), nAlerts);
         SetDlgItemText (hDlg, IDC_SET_STATUS, pszText);
         FreeString (pszText);
         }
      else // (nAlerts == 0)
         {
         if (TASKDATA(ptp)->fs.State & fsBUSY)
            GetString (szText, IDS_SETSTATUS_BUSY);
         else if (TASKDATA(ptp)->fs.State & fsSALVAGE)
            GetString (szText, IDS_SETSTATUS_SALVAGE);
         else if (TASKDATA(ptp)->fs.State & fsMOVED)
            GetString (szText, IDS_SETSTATUS_MOVED);
         else if (TASKDATA(ptp)->fs.State & fsLOCKED)
            GetString (szText, IDS_SETSTATUS_LOCKED);
         else if (TASKDATA(ptp)->fs.State & fsNO_VOL)
            GetString (szText, IDS_SETSTATUS_NO_VOL);
         else
            GetString (szText, IDS_STATUS_NOALERTS);
         SetDlgItemText (hDlg, IDC_SET_STATUS, szText);
         }

      if (TASKDATA(ptp)->fs.Type == ftREADWRITE)
         {
         Filesets_DisplayQuota (hDlg, &TASKDATA(ptp)->fs);
         }
      else
         {
         if (TASKDATA(ptp)->fs.Type == ftREPLICA)
            GetString (szText, IDS_USAGE_REPLICA);
         else // (TASKDATA(ptp)->fs.Type == ftCLONE)
            GetString (szText, IDS_USAGE_CLONE);

         pszText = FormatString (szText, TEXT("%.1B"), (double)TASKDATA(ptp)->fs.ckUsed * cb1KB);
         SetDlgItemText (hDlg, IDC_SET_USAGE, pszText);
         FreeString (pszText);

         if (GetDlgItem (hDlg, IDC_SET_USAGEBAR))
            {
            RECT rUsagebar;
            GetRectInParent (GetDlgItem (hDlg, IDC_SET_USAGEBAR), &rUsagebar);

            HFONT hf = (HFONT)SendMessage (GetDlgItem (hDlg, IDC_SET_USAGEBAR), WM_GETFONT, 0, 0);
            DestroyWindow (GetDlgItem (hDlg, IDC_SET_USAGEBAR));

            if (TASKDATA(ptp)->fs.Type == ftREPLICA)
               GetString (szText, IDS_NO_QUOTA_REPLICA);
            else // (TASKDATA(ptp)->fs.Type == ftCLONE)
               GetString (szText, IDS_NO_QUOTA_CLONE);

            HWND hDesc = CreateWindow (TEXT("static"),
                          szText,
                          WS_CHILD | SS_SIMPLE,
                          rUsagebar.left, rUsagebar.top,
                          cxRECT(rUsagebar), cyRECT(rUsagebar),
                          hDlg,
                          (HMENU)-1,
                          THIS_HINST,
                          0);
            SendMessage (hDesc, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0));
            ShowWindow (hDesc, SW_SHOW);
            }

         EnableWindow (GetDlgItem (hDlg, IDC_SET_QUOTA), FALSE);
         EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN), FALSE);
         EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_DEF), FALSE);
         EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL), FALSE);
         EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_PERCENT), FALSE);
         EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_DESC), FALSE);
         }

      if (TASKDATA(ptp)->lpsp->perWarnSetFull == 0)
         {
         GetString (szText, IDS_SETFULL_WARN_OFF);
         SetDlgItemText (hDlg, IDC_SET_WARN_SETFULL_DEF, szText);
         }
      else
         {
         GetString (szText, IDS_SETFULL_WARN_ON);
         pszText = FormatString (szText, TEXT("%lu"), TASKDATA(ptp)->lpsp->perWarnSetFull);
         SetDlgItemText (hDlg, IDC_SET_WARN_SETFULL_DEF, pszText);
         FreeString (pszText);
         }

      CheckDlgButton (hDlg, IDC_SET_WARN, (TASKDATA(ptp)->lpfp->perWarnSetFull != 0));
      if (TASKDATA(ptp)->lpfp->perWarnSetFull != 0)
         {
         if (TASKDATA(ptp)->lpfp->perWarnSetFull != -1)
            CheckDlgButton (hDlg, IDC_SET_WARN_SETFULL, TRUE);
         else
            CheckDlgButton (hDlg, IDC_SET_WARN_SETFULL_DEF, TRUE);
         }

      CreateSpinner (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_PERCENT),
                     10, FALSE,   // base, signed
                     1,
                     (TASKDATA(ptp)->lpfp->perWarnSetFull == 0 || TASKDATA(ptp)->lpfp->perWarnSetFull == -1) ? perDEFAULT_SETFULL_WARNING : TASKDATA(ptp)->lpfp->perWarnSetFull,
                     100); // min, default, max

      Filesets_General_OnWarnings (hDlg, lpi);
      }
}
Example #21
0
void SetBranding(HWND hwnd) {
    SetDlgItemText(hwnd, IDC_VERSION, g_sdata.branding);
}
static void JabberIqResultAdvancedSearch( XmlNode *iqNode, void *userdata )
{
	TCHAR* type;
	int    id;

	U_TCHAR_MAP mColumnsNames(10);
	LIST<void>  SearchResults(2);

	if ((( id = JabberGetPacketID( iqNode )) == -1 ) || (( type = JabberXmlGetAttrValue( iqNode, "type" )) == NULL )) {
		JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 );
		return;
	}

	if ( !lstrcmp( type, _T("result"))) {
		XmlNode* queryNode=JabberXmlGetNthChild(iqNode,"query",1);
		XmlNode* xNode = JabberXmlGetChildWithGivenAttrValue( queryNode, "x", "xmlns", _T("jabber:x:data"));
		if (xNode) {
			//1. Form search results info
			XmlNode* reportNode=JabberXmlGetNthChild(xNode,"reported",1);
			if (reportNode) {
				int i = 1;
				while ( XmlNode* fieldNode = JabberXmlGetNthChild( reportNode, "field", i++ )) {
					TCHAR* var = JabberXmlGetAttrValue( fieldNode, "var" );
					if ( var ) {
						TCHAR * Label=JabberXmlGetAttrValue(fieldNode,"label");
						mColumnsNames.insert(var, (Label!=NULL) ? Label : var);
			}	}	}

			int i=1;
			XmlNode* itemNode;
			while ( itemNode = JabberXmlGetNthChild( xNode, "item", i++ )) {
				U_TCHAR_MAP *pUserColumn = new U_TCHAR_MAP(10);
				int j = 1;
				while ( XmlNode* fieldNode = JabberXmlGetNthChild( itemNode, "field", j++ )) {
					if (TCHAR * var=JabberXmlGetAttrValue(fieldNode,"var" )) {
						if (TCHAR * Text=(JabberXmlGetChild(fieldNode,"value")->text)) {
							if (!mColumnsNames[var])
								mColumnsNames.insert(var,var);
							pUserColumn->insert(var,Text);
				}	}	}

				SearchResults.insert((void*)pUserColumn);
			}
		}
		else {
			//2. Field list search results info
			int i=1;
			while ( XmlNode* itemNode = JabberXmlGetNthChild( queryNode, "item", i++ )) {
				U_TCHAR_MAP *pUserColumn=new U_TCHAR_MAP(10);
				
				TCHAR* jid = JabberXmlGetAttrValue( itemNode, "jid" );
				TCHAR* keyReturned;
				mColumnsNames.insertCopyKey( _T("jid"),_T("jid"),&keyReturned, CopyKey, DestroyKey );
				mColumnsNames.insert( _T("jid"), keyReturned );
				pUserColumn->insertCopyKey( _T("jid"), jid, NULL, CopyKey, DestroyKey );

				for ( int j=0; j < itemNode->numChild; j++ ) {
					XmlNode* child = itemNode->child[j];
					if ( child->name ) {
						TCHAR * szColumnName=a2t(child->name);
						if ( child->text && child->text[0] != _T('\0')) {
							TCHAR *keyReturned;
							mColumnsNames.insertCopyKey(szColumnName,_T(""),&keyReturned, CopyKey, DestroyKey);
							mColumnsNames.insert(szColumnName,keyReturned);
							pUserColumn->insertCopyKey(szColumnName,child->text,NULL, CopyKey, DestroyKey);
							mir_free(szColumnName);
				}	}	}

				SearchResults.insert((void*)pUserColumn);
		}	}
	}
	else if (!lstrcmp( type, _T("error"))) {
		TCHAR * code=NULL;
		TCHAR * description=NULL;
		TCHAR buff[255];
		XmlNode* errorNode = JabberXmlGetChild( iqNode, "error" );
		if (errorNode) {
			code = JabberXmlGetAttrValue(errorNode,"code");
			description = errorNode->text;
		}

		_sntprintf(buff,SIZEOF(buff),TranslateT("Error %s %s\r\nTry to specify more detailed"),code ? code : _T(""),description?description:_T(""));
		JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 );
		if (searchHandleDlg )
			SetDlgItemText(searchHandleDlg,IDC_INSTRUCTIONS,buff);
		else
			MessageBox(NULL, buff, TranslateT("Search error"), MB_OK|MB_ICONSTOP);
		return;
	}

	JabberSearchReturnResults((HANDLE)id, (void*)&SearchResults, (U_TCHAR_MAP *)&mColumnsNames);

	for (int i=0; i < SearchResults.getCount(); i++ )
		delete ((U_TCHAR_MAP *)SearchResults[i]);

	//send success to finish searching
	JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 );
}
Example #23
0
INT_PTR CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	static DWORD dwOldIcon = 0;
	HICON hIcon = 0;

	switch(uMsg){
	case WM_INITDIALOG:
		g_hDlgPass = hDlg;
		hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DLGPASSWD));
		dwOldIcon = SetClassLongPtr(hDlg, GCLP_HICON, (LONG)hIcon); // set alt+tab icon
		SendDlgItemMessage(hDlg,IDC_EDIT1,EM_LIMITTEXT,MAXPASSLEN,0);

		if (IsAeroMode())
		{
			SetWindowLongPtr(hDlg, GWL_STYLE, GetWindowLongPtr(hDlg, GWL_STYLE) | WS_DLGFRAME | WS_SYSMENU);
			SetWindowLongPtr(hDlg, GWL_EXSTYLE, GetWindowLongPtr(hDlg, GWL_EXSTYLE) | WS_EX_TOOLWINDOW);
			RECT rect;
			GetClientRect(hDlg, &rect);
			SetWindowPos(hDlg, 0, 0, 0, rect.right, rect.bottom + GetSystemMetrics(SM_CYCAPTION), SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER);
		}
		SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)hIcon);
		SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Miranda NG is locked.\nEnter password to unlock it."));

		TranslateDialogDefault(hDlg);
		oldLangID = 0;
		SetTimer(hDlg,1,200,NULL);

		oldLayout = GetKeyboardLayout(0);
		if (MAKELCID((WORD)oldLayout & 0xffffffff,  SORT_DEFAULT) != (LCID)0x00000409)
			ActivateKeyboardLayout((HKL)0x00000409, 0);
		LanguageChanged(hDlg);
		return TRUE;

	case WM_CTLCOLORSTATIC:
		if (GetWindowLongPtr((HWND)lParam, GWLP_ID) != IDC_LANG)
			break;

		SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
		SetBkMode((HDC)wParam, TRANSPARENT);
		return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT);

	case WM_COMMAND:
		{
			UINT uid = LOWORD(wParam);
			if (uid == IDOK){
				char password[MAXPASSLEN + 1] = {0};
				int passlen = GetDlgItemTextA(hDlg,IDC_EDIT1,password,MAXPASSLEN+1);

				if (passlen == 0)
				{
					SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Miranda NG is locked.\nEnter password to unlock it."));
					SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_NCPAINT, 0, 0);
					break;
				}
				else if (lstrcmpA(password, g_password))
				{
					SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Password is not correct!\nPlease, enter correct password."));
					SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_NCPAINT, 0, 0);
					SetDlgItemText(hDlg, IDC_EDIT1, _T(""));
					break;
				}
				else EndDialog(hDlg, IDOK);
			}
			else if (uid == IDCANCEL)
				EndDialog(hDlg, IDCANCEL);
		}

	case WM_TIMER:
		LanguageChanged(hDlg);
		break;

	case WM_DESTROY:
		KillTimer(hDlg, 1);
		if (GetKeyboardLayout(0) != oldLayout)
			ActivateKeyboardLayout(oldLayout, 0);
		SetClassLongPtr(hDlg, GCLP_HICON, (long)dwOldIcon);
		DestroyIcon(hIcon);
		break;
	}
	return FALSE;
}
Example #24
0
INT_PTR CALLBACK GameTitleProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	//RECT r;
	//RECT r2;
	//int dx1, dy1, dx2, dy2;

	static bool bUpdatingTextboxTitle = false;

 	switch(uMsg)
 	{
 	case WM_INITDIALOG:
	{
		HWND hKnownGamesCbo = GetDlgItem( hDlg, IDC_RA_KNOWNGAMES );
		char sGameTitleTidy[64];
		char buffer[65535];
		char* pBuffer = &buffer[0];
		int nSel = 0;
		const char* NewLine = "\n";
		char* pNextTitle = NULL;

		strcpy_s( sGameTitleTidy, 64, g_GameTitleDialog.m_sEstimatedGameTitle );
		Dlg_GameTitle::CleanRomName( sGameTitleTidy, 64 );

		SetDlgItemText( hDlg, IDC_RA_GAMETITLE, sGameTitleTidy );

		if( strlen( g_pActiveAchievements->m_sPreferredGameTitle ) < 2 )
		{
		}
		else
		{
			//	Why would you ever want this one?
			//SetDlgItemText( hDlg, IDC_RA_GAMETITLE, g_pActiveAchievements->m_sPreferredGameTitle );
		}

		//	Load in the checksum
		SetDlgItemText( hDlg, IDC_RA_CHECKSUM, g_GameTitleDialog.m_sMD5 );


		//	Populate the dropdown
		//	***Do blocking fetch of all game titles.***
		ZeroMemory( buffer, 65535 );
		
		nSel = ComboBox_AddString( hKnownGamesCbo, "<New Title>" );
		ComboBox_SetCurSel( hKnownGamesCbo, nSel );

		{
			char postBuffer[256];
			sprintf_s( postBuffer, 256, "c=%d", g_ConsoleID );
			DWORD nBytesRead = 0;
			if( DoBlockingHttpPost( "requestallgametitles.php", postBuffer, pBuffer, 65535, &nBytesRead ) )
			{
				if( strncmp( pBuffer, "OK:", 3 ) == 0 )
				{
					pBuffer += 3;

					pNextTitle = strtok_s( pBuffer, NewLine, &pBuffer );
					while( pNextTitle != NULL )
					{
						nSel = ComboBox_AddString( hKnownGamesCbo, pNextTitle );

						if( _stricmp( sGameTitleTidy, pNextTitle ) == 0 )
							ComboBox_SetCurSel( hKnownGamesCbo, nSel );

						pNextTitle = strtok_s( pBuffer, NewLine, &pBuffer );
					}
				}
			}
		}

		return TRUE;
	}
	break;
 
 	case WM_COMMAND:
 		switch( LOWORD(wParam) )
 		{
 		case IDOK:
 			{
				//	Fetch input data:
				char sSelectedTitle[512];
 				char sRequest[512];
 				char sResponse[4096];
				const char* sDestPage = NULL;
 				DWORD nBytesRead = 0;
  				
				HWND hKnownGamesCbo = GetDlgItem( hDlg, IDC_RA_KNOWNGAMES );

				ComboBox_GetText( hKnownGamesCbo, sSelectedTitle, 512 );

				if( strcmp( sSelectedTitle, "<New Title>" ) == 0 )
				{
					//	Add a new title!
 					GetDlgItemText( hDlg, IDC_RA_GAMETITLE, sSelectedTitle, 512 );
 					sDestPage = "requestsubmitgametitle.php";
				}
				else
				{
					//	Add an alt!
					sDestPage = "requestsubmitalt.php";
				}
				
				//	Pack query string:
 				sprintf_s( sRequest, 512, "u=%s&t=%s&m=%s&g=%s&c=%d", 
					g_LocalUser.m_sUsername, g_LocalUser.m_sToken, g_GameTitleDialog.m_sMD5, sSelectedTitle, g_ConsoleID );

				//	Send request:
				ZeroMemory( sResponse, 4096 );

 				if( DoBlockingHttpPost( sDestPage, sRequest, sResponse, 4096, &nBytesRead ) &&
					strncmp( sResponse, "OK:", 3 ) == 0 )
 				{
 					//g_pActiveAchievements->SetGameTitle( sSelectedTitle );
					CoreAchievements->SetGameTitle( sSelectedTitle );
					UnofficialAchievements->SetGameTitle( sSelectedTitle );
					LocalAchievements->SetGameTitle( sSelectedTitle );
 
					g_GameTitleDialog.m_nReturnedGameID = strtol( sResponse+3, NULL, 10 );

 					//	Close this dialog
 					EndDialog( hDlg, TRUE );
 					return TRUE;
 				}
 				else
 				{
					char bufferFeedback[2048];
 					sprintf_s( bufferFeedback, 2048, "Failed!\n\nResponse From Server:\n\n%s", sResponse );
 					MessageBox( hDlg, bufferFeedback, "Error from server!", MB_OK );
 
 					return TRUE;
 				}
 			}
 		case IDCANCEL:
 			EndDialog( hDlg, TRUE );
 			return TRUE;
 			break;
		case IDC_RA_GAMETITLE:
			switch( HIWORD(wParam) )
			{
				case EN_CHANGE:
				{
					if( !bUpdatingTextboxTitle )	//	Note: use barrier to prevent automatic switching off.
					{
						//	If the user has started to enter a value, set the upper combo to 'new entry'
						HWND hKnownGamesCbo = GetDlgItem( hDlg, IDC_RA_KNOWNGAMES );
						ComboBox_SetCurSel( hKnownGamesCbo, 0 );
					}
				}
				break;
			}
			break;
		case IDC_RA_KNOWNGAMES:
			switch( HIWORD(wParam) )
			{
				case CBN_SELCHANGE:
				{
					//	If the user has selected a value, copy this text to the bottom textbox.
					bUpdatingTextboxTitle = TRUE;

					char sSelectedTitle[512];
 					GetDlgItemText( hDlg, IDC_RA_KNOWNGAMES, sSelectedTitle, 512 );
					SetDlgItemText( hDlg, IDC_RA_GAMETITLE, sSelectedTitle );
					
					bUpdatingTextboxTitle = FALSE;
				}
				break;
			}
			break;
 		}
 		break;
 	case WM_KEYDOWN:
		//IDC_RA_GAMETITLE
		wParam;
		break;
 	case WM_CLOSE:
 		// 		if (Full_Screen)
 		// 		{
 		// 			while (ShowCursor(true) < 0);
 		// 			while (ShowCursor(false) >= 0);
 		// 		}
 
 		EndDialog( hDlg, FALSE );
 		return TRUE;
 		break;
 	}

	return FALSE;
}
Example #25
0
static INT_PTR CALLBACK DlgProcSetStatusMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		SendDlgItemMessage(hwndDlg, IDC_STATUSMESSAGE, EM_LIMITTEXT, MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE - 1, 0);
		mir_subclassWindow(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), StatusMsgEditSubclassProc);
		return TRUE;

	case WMU_SETDATA:
	{
		SetStatusMessageData *data = (SetStatusMessageData *)malloc(sizeof(SetStatusMessageData));
		data->status = (int)wParam;
		data->proto_num = (int)lParam;

		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)data);

		if (data->proto_num >= 0) {
			Protocol *proto = protocols->Get(data->proto_num);

			HICON hIcon = (HICON)CallProtoService(proto->name, PS_LOADICON, PLI_PROTOCOL, 0);
			if (hIcon != NULL) {
				SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
				DestroyIcon(hIcon);
			}

			TCHAR title[256];
			mir_sntprintf(title, _countof(title), TranslateT("Set my status message for %s"), proto->description);
			SetWindowText(hwndDlg, title);

			SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, proto->GetStatusMsg());
		}
		else if (data->status != 0) {
			SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_LoadProtoIcon(NULL, data->status));

			TCHAR title[256];
			mir_sntprintf(title, _countof(title), TranslateT("Set my status message for %s"), pcli->pfnGetStatusModeDescription(data->status, 0));
			SetWindowText(hwndDlg, title);

			SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, protocols->GetDefaultStatusMsg(data->status));
		}
		else {
			SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_MIRANDA));

			SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, protocols->GetDefaultStatusMsg());
		}

		return TRUE;
	}
	case WM_COMMAND:
		switch (wParam) {
		case IDOK:
		{
			TCHAR tmp[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE];
			GetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, tmp, _countof(tmp));

			SetStatusMessageData *data = (SetStatusMessageData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

			if (data->proto_num >= 0)
				protocols->Get(data->proto_num)->SetStatusMsg(tmp);
			else if (data->status == 0)
				protocols->SetStatusMsgs(tmp);
			else
				protocols->SetStatusMsgs(data->status, tmp);

			DestroyWindow(hwndDlg);
		}
		break;

		case IDCANCEL:
			DestroyWindow(hwndDlg);
			break;
		}
		break;

	case WM_CLOSE:
		DestroyWindow(hwndDlg);
		break;

	case WM_DESTROY:
		SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), GWLP_WNDPROC,
			GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), GWLP_USERDATA));
		free((SetStatusMessageData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
		InterlockedExchange(&status_msg_dialog_open, 0);
		break;
	}

	return FALSE;
}
//------------------------------------------------------------------------------
// Name: SetCurrentStatus()
// Desc: Update the controls.
//------------------------------------------------------------------------------
void SetCurrentStatus( AUDIOSTATUS currentStatus )
{
	RECT rect;

	switch( currentStatus )
	{	
	case READY:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Ready" ) );
		
		GetWindowRect( g_hwndDialog, &rect );
		MoveWindow( g_hwndDialog,
					rect.left,
					rect.top,
					rect.right - rect.left,
					( UINT )( SMALLDLGSIZE *  g_iDlgHeight ),
					TRUE );

		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), TRUE );

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, FALSE, 0 );
		return;

	case OPENING:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Opening..." ) );

		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PLAY ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), FALSE );

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, TRUE, 0 );
		SetFocus( GetDlgItem( g_hwndDialog, IDC_STOP ) );
		break;

	case PLAY:
		//
		// Reset the global variable which might have been set while seeking
		// or stop operation
		//
		g_IsSeeking = FALSE;

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Playing..." ) );

		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PLAY ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), g_pAudioplay->IsSeekable() );
        {
            DWORD_PTR max = SendDlgItemMessage( g_hwndDialog, IDC_SLIDER, TBM_GETRANGEMAX, 0,0 );
        }

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, ( WPARAM )TRUE, 0 );

		GetWindowRect( g_hwndDialog, &rect );
		MoveWindow( g_hwndDialog,
					rect.left,
					rect.top,
					rect.right - rect.left,
					g_iDlgHeight,
					TRUE );

		if( !g_pAudioplay->IsBroadcast() )
		{
			EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), TRUE );
		    SetFocus( GetDlgItem( g_hwndDialog, IDC_PAUSE ) );
		}
        else
        {
			EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		    SetFocus( GetDlgItem( g_hwndDialog, IDC_STOP ) );
        }

		break;

	case PAUSE:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Paused" ) );
		
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PLAY ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), FALSE );

		SetFocus( GetDlgItem(g_hwndDialog, IDC_PLAY ) );

		break;

	case CLOSED:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "" ) );

		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PLAY ), TRUE );

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, ( WPARAM )FALSE, 0 );
		SendDlgItemMessage( g_hwndDialog, IDC_SLIDER , TBM_SETPOS, TRUE, 0 );
		SendDlgItemMessageW( g_hwndDialog, IDC_DURATION, WM_SETTEXT, 0, ( WPARAM )L"" );

		GetWindowRect( g_hwndDialog, &rect );
		MoveWindow( g_hwndDialog,
					rect.left,
					rect.top,
					rect.right - rect.left,
					( UINT )( SMALLDLGSIZE * g_iDlgHeight),
					TRUE );
		break;

	case STOP:
		
		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Stopped" ) );
		
		SendDlgItemMessage( g_hwndDialog, IDC_SLIDER , TBM_SETPOS, TRUE, 0 ); 

        EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PLAY ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), FALSE );

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, ( WPARAM ) FALSE, 0 );

		SetFocus( GetDlgItem( g_hwndDialog, IDC_PLAY ) );

		g_IsSeeking = FALSE;
        SetTime( 0, g_pAudioplay->GetFileDuration() );

		break;

	case BUFFERING:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Buffering..." ) );
		return;

	case STOPPING:
		//
		// Since we are going to position the trackbar at the beginning,
		// set the global variable
		//
		g_IsSeeking = TRUE;
		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Trying to Stop...Please Wait" ) );
			
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), FALSE );

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, ( WPARAM )TRUE, 0 );
		SetFocus( GetDlgItem( g_hwndDialog, IDC_STATUS ) );

		return;

	case ACQUIRINGLICENSE:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Acquiring License..." ) );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), TRUE );

		{
			LPTSTR ptszFile = _tcsrchr( g_ptszFileName, _T( '\\' ) );
            if( NULL == ptszFile )
            {
			    SetWindowText( g_hwndDialog, g_ptszFileName );
            }
            else
            {
			    SetWindowText( g_hwndDialog, ptszFile + 1 );
            }
		}

		SetFocus( GetDlgItem( g_hwndDialog, IDC_STOP ) );
		break;

	case INDIVIDUALIZING:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Individualizing..." ) );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), TRUE );

		{
			LPTSTR ptszFile = _tcsrchr( g_ptszFileName, _T( '\\' ) );
            if( NULL == ptszFile )
            {
			    SetWindowText( g_hwndDialog, g_ptszFileName );
            }
            else
            {
			    SetWindowText( g_hwndDialog, ptszFile + 1 );
            }
		}

		SetFocus( GetDlgItem( g_hwndDialog, IDC_STOP ) );
		break;

	case LICENSEACQUIRED:
		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "License acquired" ) );
		break;

	case INDIVIDUALIZED:
		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Individualization complete" ) );
		break;
	
	default:
		return;
	}

	g_Status = currentStatus;
}
Example #27
0
INT_PTR CALLBACK DlgProcSettings(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static TCHAR customCommand[MAX_PATH] = {0};
	static TCHAR customText[TITLE_SIZE] = {0};
	static TCHAR szKeyTemp[MAX_PATH + GUID_STRING_SIZE];

	static DWORD showMenu = 2;	//0 off, 1 on, 2 unknown
	static DWORD useMenuIcon = 1;	// 0 off, otherwise on

	HKEY settingKey;
	LONG result;
	DWORD size = 0;

	switch(uMsg)
	{
		case WM_INITDIALOG:
		{
			wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID);
			result = RegOpenKeyEx(HKEY_CLASSES_ROOT, szKeyTemp, 0, KEY_READ, &settingKey);
			if (result == ERROR_SUCCESS)
			{
				size = sizeof(TCHAR)*TITLE_SIZE;
				result = RegQueryValueEx(settingKey, TEXT("Title"), NULL, NULL, (LPBYTE)(customText), &size);
				if (result != ERROR_SUCCESS)
				{
					lstrcpyn(customText, szDefaultMenutext, TITLE_SIZE);
				}

				size = sizeof(TCHAR)*MAX_PATH;
				result = RegQueryValueEx(settingKey, TEXT("Custom"), NULL, NULL, (LPBYTE)(customCommand), &size);
				if (result != ERROR_SUCCESS)
				{
					lstrcpyn(customCommand, TEXT(""), MAX_PATH);
				}

				size = sizeof(DWORD);
				result = RegQueryValueEx(settingKey, TEXT("Dynamic"), NULL, NULL, (BYTE*)(&isDynamic), &size);
				if (result != ERROR_SUCCESS)
				{
					isDynamic = 1;
				}

				size = sizeof(DWORD);
				result = RegQueryValueEx(settingKey, TEXT("ShowIcon"), NULL, NULL, (BYTE*)(&useMenuIcon), &size);
				if (result != ERROR_SUCCESS)
				{
					useMenuIcon = 1;
				}

				RegCloseKey(settingKey);
			}

			Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_USECONTEXT), BST_INDETERMINATE);
			Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_USEICON), BST_INDETERMINATE);

			Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_CONTEXTICON), useMenuIcon?BST_CHECKED:BST_UNCHECKED);
			Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_ISDYNAMIC), isDynamic?BST_CHECKED:BST_UNCHECKED);

			SetDlgItemText(hwndDlg, IDC_EDIT_MENU, customText);
			SetDlgItemText(hwndDlg, IDC_EDIT_COMMAND, customCommand);

			return TRUE;
			break;
		}

		case WM_COMMAND:
		{
			switch(LOWORD(wParam))
			{
				case IDOK:
				{
					//Store settings
					GetDlgItemText(hwndDlg, IDC_EDIT_MENU, customText, TITLE_SIZE);
					GetDlgItemText(hwndDlg, IDC_EDIT_COMMAND, customCommand, MAX_PATH);
					int textLen = lstrlen(customText);
					int commandLen = lstrlen(customCommand);

					wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID);
					result = RegCreateKeyEx(HKEY_CLASSES_ROOT, szKeyTemp, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &settingKey, NULL);
					if (result == ERROR_SUCCESS)
					{
						result = RegSetValueEx(settingKey, TEXT("Title"), 0,REG_SZ, (LPBYTE)customText, (textLen+1)*sizeof(TCHAR));
						result = RegSetValueEx(settingKey, TEXT("Custom"), 0,REG_SZ, (LPBYTE)customCommand, (commandLen+1)*sizeof(TCHAR));

						result = RegSetValueEx(settingKey, TEXT("Dynamic"), 0, REG_DWORD, (LPBYTE)&isDynamic, sizeof(DWORD));
						result = RegSetValueEx(settingKey, TEXT("ShowIcon"), 0, REG_DWORD, (LPBYTE)&useMenuIcon, sizeof(DWORD));

						RegCloseKey(settingKey);
					}

					if (showMenu == 1)
					{
						result = RegCreateKeyEx(HKEY_CLASSES_ROOT, szShellExtensionKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &settingKey, NULL);
						if (result == ERROR_SUCCESS)
						{
							result = RegSetValueEx(settingKey, NULL, 0,REG_SZ, (LPBYTE)szGUID, (lstrlen(szGUID)+1)*sizeof(TCHAR));
							RegCloseKey(settingKey);
						}
					}
					else if (showMenu == 0)
					{
						RegDeleteKey(HKEY_CLASSES_ROOT, szShellExtensionKey);
					}

					if (showIcon == 1)
					{
						result = RegCreateKeyEx(HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex\\IconHandler"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &settingKey, NULL);
						if (result == ERROR_SUCCESS)
						{
							result = RegSetValueEx(settingKey, NULL, 0,REG_SZ, (LPBYTE)szGUID, (lstrlen(szGUID)+1)*sizeof(TCHAR));
							RegCloseKey(settingKey);
						}
					}
					else if (showIcon == 0)
					{
						RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex\\IconHandler"));
						RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex"));
					}

					PostMessage(hwndDlg, WM_CLOSE, 0, 0);
					break;
				}

				case IDC_CHECK_USECONTEXT:
				{
					int state = Button_GetCheck((HWND)lParam);
					if (state == BST_CHECKED)
						showMenu = 1;
					else if (state == BST_UNCHECKED)
						showMenu = 0;
					else
						showMenu = 2;
					break;
				}

				case IDC_CHECK_USEICON:
				{
					int state = Button_GetCheck((HWND)lParam);
					if (state == BST_CHECKED)
						showIcon = 1;
					else if (state == BST_UNCHECKED)
						showIcon = 0;
					else
						showIcon = 2;
					break;
				}

				case IDC_CHECK_CONTEXTICON:
				{
					int state = Button_GetCheck((HWND)lParam);
					if (state == BST_CHECKED)
						useMenuIcon = 1;
					else
						useMenuIcon = 0;
					break;
				}

				case IDC_CHECK_ISDYNAMIC:
				{
					int state = Button_GetCheck((HWND)lParam);
					if (state == BST_CHECKED)
						isDynamic = 1;
					else
						isDynamic = 0;
					break;
				}

				default:
					break;
			}

			return TRUE;
			break;
		}

		case WM_CLOSE:
			EndDialog(hwndDlg, 0);
			return TRUE;

		default:
			break;
	}

	return FALSE;
}
//------------------------------------------------------------------------------
// Name: DlgProc()
// Desc: Dialog box procedure.
//------------------------------------------------------------------------------
INT_PTR CALLBACK DlgProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	HRESULT	hr		= S_OK;
	HICON	hIcon	= NULL;
	RECT	rect;

	switch( uMsg )
	{
	case WM_INITDIALOG:
		
		g_hwndDialog = hwndDlg;

		//
		// Load the application icon
		//
		hIcon = LoadIcon( g_hInst, MAKEINTRESOURCE( IDI_WMAICON ) );
		if( hIcon )
		{
			SendMessage( hwndDlg, WM_SETICON, ICON_SMALL, ( LPARAM )hIcon );
			SendMessage( hwndDlg, WM_SETICON, ICON_BIG, ( LPARAM )hIcon );
		}

		GetWindowRect( hwndDlg, &rect );

		//
		// Store the Window height in a global variable for future reference
		//
		g_iDlgHeight = rect.bottom - rect.top;

        //
        // Ready to open and play a file
        //
		SetCurrentStatus( READY );
		
        //
        // Create and initialize the audio player
        //
        g_pAudioplay = new CAudioPlay;
        if( NULL == g_pAudioplay )
        {
			//
			// Creation has failed. Close the application.
			//
			SendMessage( hwndDlg, WM_CLOSE, 0,0 );
            return TRUE;
        }

		hr = g_pAudioplay->Init();
		if( FAILED(hr) )
		{
			//
			// Init has failed. Close the application.
			//
			SendMessage( hwndDlg, WM_CLOSE, 0,0 );
		}

		return TRUE;

	case WM_COMMAND:

		switch( LOWORD( wParam ) ) 
		{
		case IDC_FILENAME:

			if( EN_CHANGE == HIWORD( wParam ) )
			{
				//
                // Filename has been changed
				// Use this notification for enabling or disabling the Play button
				//
				TCHAR tszFileName[ MAX_PATH ];

				GetDlgItemText( hwndDlg, IDC_FILENAME, tszFileName, MAX_PATH );

                //
                // If filename is not empty, enable the Play button
                //
				if( _tcslen( tszFileName) > 0 )
				{
					EnableWindow( GetDlgItem( hwndDlg, IDC_PLAY ), TRUE );

					SetCurrentStatus( CLOSED );
				}
				else
				{
					EnableWindow( GetDlgItem( hwndDlg, IDC_PLAY ), FALSE );
				}
				
				SetCurrentStatus( READY );
				
				return TRUE;
			}
			
			return FALSE;

		case IDC_OPEN:

            //
            // Show the OpenFile dialog
            //
			if( ShowOpenFileDialog() )
			{
				//
				// Display the file name
				//
				SetDlgItemText( hwndDlg, IDC_FILENAME, g_ptszFileName );

				SetFocus( GetDlgItem( hwndDlg, IDC_PLAY ) );
			}

			return TRUE;
		
		case IDC_STOP:
			
			SetCurrentStatus( STOPPING );

            //
            // Stop the audio player
            //
            if( NULL != g_pAudioplay )
            {
			    hr = g_pAudioplay->Stop();
			    if( FAILED( hr ) )
			    {
				    SetCurrentStatus( g_Status );

				    TCHAR tszErrMesg[128];
                    (void)StringCchPrintf( tszErrMesg, ARRAYSIZE(tszErrMesg), _T( "Unable to Stop (hr=%#X)" ), hr );
				    MessageBox( hwndDlg, tszErrMesg, ERROR_DIALOG_TITLE, MB_OK );
			    }
            }

			return TRUE;
			
		case IDC_PAUSE:
			
            //
            // Pause the audio player
            //
            if( NULL != g_pAudioplay )
            {
			    hr = g_pAudioplay->Pause();
			    if( FAILED( hr ) )
			    {
				    TCHAR tszErrMesg[128];
                    (void)StringCchPrintf( tszErrMesg, ARRAYSIZE(tszErrMesg), _T("Unable to Pause (hr=%#X)"), hr );
				    MessageBox( hwndDlg, tszErrMesg, ERROR_DIALOG_TITLE, MB_OK );
			    }
			    else
			    {
				    SetCurrentStatus( PAUSE );
			    }
            }

			break;
		
		case IDC_PLAY:
			
			return( OnPlay() );

		case IDCANCEL:
			//
			// Close the player before exiting application
			//
            if( NULL != g_pAudioplay )
            {
			    g_pAudioplay->Exit();
			    g_pAudioplay->Release();
            }

			EndDialog( hwndDlg, wParam );

			return TRUE;
		}
		break;

	case WM_HSCROLL:

        if( NULL == g_pAudioplay )
        {
            break;
        }

		//
		// Seek only when the file is seekable
		//
		if( ( LOWORD( wParam ) == TB_THUMBTRACK || 
			  LOWORD( wParam ) == TB_BOTTOM ||
			  LOWORD( wParam ) == TB_PAGEDOWN ||
			  LOWORD( wParam ) == TB_PAGEUP ||
			  LOWORD( wParam ) == TB_TOP ) &&
            g_pAudioplay->IsSeekable() )
		{
			//
			// Set g_IsSeeking, to be referenced when thumb tracking is over
			//
			g_IsSeeking = TRUE;
		}
		else if( LOWORD( wParam ) == TB_ENDTRACK && g_pAudioplay->IsSeekable() && g_IsSeeking )
		{
			DWORD_PTR dwPos = SendDlgItemMessage( hwndDlg, IDC_SLIDER, TBM_GETPOS, 0, 0 );

			// 
			// Start the file from the new position
			//
			hr = g_pAudioplay->Start( ( QWORD )dwPos * 10000 );
			if( FAILED ( hr ) )
			{
				g_IsSeeking = FALSE;
			}
		}

		break;
	}

    return FALSE;
}
Example #29
0
HRESULT CALLBACK OpenCell_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
   LPOPENCELLDLG_PARAMS lpp;
   if (msg == WM_INITDIALOG)
      SetWindowLongPtr (hDlg, DWLP_USER, lp);

   if ((lpp = (LPOPENCELLDLG_PARAMS)GetWindowLongPtr (hDlg, DWLP_USER)) != NULL)
      {
      if (lpp->hookproc)
         {
         if (CallWindowProc ((WNDPROC)lpp->hookproc, hDlg, msg, wp, lp))
            return TRUE;
         }
      }

   if (lpp != NULL)
      {
      if (AfsAppLib_HandleHelp (lpp->idd, hDlg, msg, wp, lp))
         return TRUE;
      }

   switch (msg)
      {
      case WM_INITDIALOG:
         OpenCell_OnInitDialog (hDlg, lpp);
         break;

      case WM_COMMAND:
         switch (LOWORD(wp))
            {
            case IDCANCEL:
               EndDialog (hDlg, IDCANCEL);
               return TRUE;

            case IDOK:
               if (OpenCell_OnOK (hDlg, lpp))
                  EndDialog (hDlg, IDOK);
               return TRUE;

            case IDC_OPENCELL_CELL:
               switch (HIWORD(wp))
                  {
                  case CBN_SELCHANGE:
                     TCHAR szCell[ cchNAME ];
                     SendDlgItemMessage (hDlg, IDC_OPENCELL_CELL, CB_GETLBTEXT, CB_GetSelected(GetDlgItem (hDlg, IDC_OPENCELL_CELL)), (LPARAM)szCell);
                     SetDlgItemText (hDlg, IDC_OPENCELL_CELL, szCell);
                     OpenCell_OnCell (hDlg);
                     break;

                  case CBN_EDITCHANGE:
                     OpenCell_OnCell (hDlg);
                     break;
                  }
               break;
            }
         break;

      case WM_REFRESHED_CREDENTIALS:
         OpenCell_OnGotCreds (hDlg, lp);
         break;
      }

   return FALSE;
}
Example #30
0
INT_PTR CALLBACK
ProxySettingsDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, UNUSED LPARAM lParam)
{
    HICON hIcon;
    LPPSHNOTIFY psn;

    switch (msg)
    {
    case WM_INITDIALOG:
        hIcon = LoadLocalizedIcon(ID_ICO_APP);
        if (hIcon)
        {
            SendMessage(hwndDlg, WM_SETICON, (WPARAM) (ICON_SMALL), (LPARAM) (hIcon));
            SendMessage(hwndDlg, WM_SETICON, (WPARAM) (ICON_BIG), (LPARAM) (hIcon));
        }

        /* Limit Port editbox to 5 chars. */
        SendMessage(GetDlgItem(hwndDlg, ID_EDT_PROXY_PORT), EM_SETLIMITTEXT, 5, 0);

        LoadProxySettings(hwndDlg);
        break;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case ID_RB_PROXY_OPENVPN:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_HTTP), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_SOCKS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_ADDRESS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_PORT), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_ADDRESS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_PORT), FALSE);
            }
            break;

        case ID_RB_PROXY_MSIE:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_HTTP), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_SOCKS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_ADDRESS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_PORT), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_ADDRESS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_PORT), FALSE);
            }
            break;

        case ID_RB_PROXY_MANUAL:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_HTTP), TRUE);
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_SOCKS), TRUE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_ADDRESS), TRUE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_PORT), TRUE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_ADDRESS), TRUE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_PORT), TRUE);
            }
            break;

        case ID_RB_PROXY_HTTP:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                SetDlgItemText(hwndDlg, ID_EDT_PROXY_ADDRESS, o.proxy_http_address);
                SetDlgItemText(hwndDlg, ID_EDT_PROXY_PORT, o.proxy_http_port);
            }
            break;

        case ID_RB_PROXY_SOCKS:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                SetDlgItemText(hwndDlg, ID_EDT_PROXY_ADDRESS, o.proxy_socks_address);
                SetDlgItemText(hwndDlg, ID_EDT_PROXY_PORT, o.proxy_socks_port);
            }
            break;
        }
        break;

    case WM_NOTIFY:
        psn = (LPPSHNOTIFY) lParam;
        if (psn->hdr.code == (UINT) PSN_KILLACTIVE)
        {
            SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (CheckProxySettings(hwndDlg) ? FALSE : TRUE));
            return TRUE;
        }
        else if (psn->hdr.code == (UINT) PSN_APPLY)
        {
            SaveProxySettings(hwndDlg);
            SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
            return TRUE;
        }
        break;

    case WM_CLOSE:
        EndDialog(hwndDlg, LOWORD(wParam));
        return TRUE;
    }
    return FALSE;
}