Beispiel #1
0
void TraverseTreebarItems(void)
{
	SetWindowRedraw(Dcx::mIRC.getTreeview(), FALSE);
	TString buf((UINT)MIRC_BUFFER_SIZE_CCH);
	TString res;
	TVITEMEX item;
	ZeroMemory(&item, sizeof(item));
	for (HTREEITEM ptvitem = TreeView_GetRoot(Dcx::mIRC.getTreeview()); ptvitem != NULL; ptvitem = TreeView_GetNextSibling(Dcx::mIRC.getTreeview(), ptvitem)) {
		item.hItem = ptvitem;
		item.pszText = buf.to_chr();
		item.cchTextMax = MIRC_BUFFER_SIZE_CCH;
		item.mask = TVIF_TEXT|TVIF_PARAM;
		if (TreeView_GetItem(Dcx::mIRC.getTreeview(), &item))
		{
			{
				TString tsType;
				DcxDock::getTreebarItemType(tsType, item.lParam);
				Dcx::mIRC.execex("/!set -nu1 %%dcx_%d %s", item.lParam, item.pszText );
				Dcx::mIRC.tsEvalex(res, "$xtreebar_callback(geticons,%s,%%dcx_%d)", tsType.to_chr(), item.lParam);
			}
			item.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE;
			int i = res.gettok( 1 ).to_int() -1;
			if (i < 0)
				i = 0;
			item.iImage = i;
			i = res.gettok( 2 ).to_int() -1;
			if (i < 0)
				i = 0;
			item.iSelectedImage = i;
			TreeView_SetItem(Dcx::mIRC.getTreeview(), &item);
		}
		TraverseChildren(ptvitem, buf, res, &item);
	}
	SetWindowRedraw(Dcx::mIRC.getTreeview(), TRUE);
}
Beispiel #2
0
void ListBox_MoveAllStrings(HWND hwndListBox, int iAmount)
{
    int iCount = ListBox_GetSelCount(hwndListBox), i;
    LPINT lpiItems = (LPINT)Mem_Alloc(iCount * sizeof(INT));

    SetWindowRedraw(hwndListBox, FALSE);

    ListBox_GetSelItems(hwndListBox, iCount, lpiItems);

    if (iAmount < 0)
    {
        for (i = 0; i < iCount; i++)
        {
            int nIndex = ListBox_MoveString(hwndListBox, lpiItems[i], iAmount, TRUE);
            ASSERT(nIndex != LB_ERR);
        }
    }
    else
    {
        for (i = (iCount - 1); i > -1; i--)
        {
            int nIndex = ListBox_MoveString(hwndListBox, lpiItems[i], iAmount, TRUE);
            ASSERT(nIndex != LB_ERR);
        }
    }

    // Reselect all the items moved
    for (i = 0; i < iCount; i++)
        ListBox_SetSel(hwndListBox, TRUE, lpiItems[i] + iAmount);

    SetWindowRedraw(hwndListBox, TRUE);
    RedrawWindow(hwndListBox, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);

    Mem_Free(lpiItems);
}
Beispiel #3
0
LOCAL void DragEnd(HWND hWindow)
/***********************************************************************/
{
// get the listbox data pointer, if we don't have one, get out
LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	return;

// see if we ever started dragging
if (lpData->fDragging)
	{
	// if we had a cursor, reset it
	if (lpData->hCursor)
		SetCursor(lpData->hOldCursor);
    // do the move if we successfully dragged
    if (lpData->fSuccess) 
    	{
        int nItem, iTopItem;       
        TCHAR szString[256];  
        
		// save the top index, so we can reset it
		iTopItem = ListBox_GetTopIndex(hWindow);
        // turn of painting while working with list
		SetWindowRedraw(hWindow, FALSE);
        // save text of item
		ListBox_GetText(hWindow, lpData->iOldPos, szString);
        
        // delete the item
		ListBox_DeleteString(hWindow, lpData->iOldPos);
             
		// adjust index because of DeleteString
		int iNewPos = lpData->iNewPos;
        if (iNewPos > lpData->iOldPos)
        	iNewPos--;
      	// add the new string at the right spot                       
		nItem = ListBox_InsertString(hWindow, iNewPos, szString);

		// select the item we moved
		DWORD dwStyle = GetWindowLong(hWindow, GWL_STYLE);
		if (dwStyle & (LBS_MULTIPLESEL, LBS_EXTENDEDSEL))
	        ListBox_SetSel(hWindow, TRUE, nItem);
		else
	        ListBox_SetCurSel(hWindow, nItem);

		// reset the top index
		ListBox_SetTopIndex(hWindow, iTopItem);
		// turn drawing back on
		SetWindowRedraw(hWindow, TRUE);
		// inform the dialog of the move
		FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow),
							hWindow, LBN_MOVEITEM, SendMessage);
       	}
   	}
// turn off dragging
lpData->fDragging = FALSE;    
KillTimer(hWindow, lpData->idTimer);    
}
Beispiel #4
0
void Dlg_CreateReport (HWND hwndEdit) {
   TCHAR szBuf[500];    // Line buffer
   int   i, nVisLine;
   DWORD dwMin, dwMax;
   float rAvg, rStdDev;

   // Disable updates to prevent the edit box from scrolling.
   SetWindowRedraw(hwndEdit, FALSE);

   Dlg_IntervalStat(g_pdwTickSamples, g_nSamplesMax, &dwMin,
      &dwMax, &rAvg, &rStdDev);

   // Clear the report.
   Edit_SetText(hwndEdit, _TEXT(""));

   // Write the report.
   _stprintf(szBuf, 
      _TEXT("Period (mS):  %lu\r\n")
      _TEXT("Sample Size:  %lu\r\n")
      _TEXT("\r\n")
      _TEXT("Interval Statistics\r\n")
      _TEXT("   Avg. Period:  %.3f\r\n")
      _TEXT("   Min. Period:  %lu\r\n")
      _TEXT("   Max. Period:  %lu\r\n")
      _TEXT("   Standard Dev.:  %.3f\r\n")
      _TEXT("\r\n")
      _TEXT("Timer Samples:"),
      g_uPeriod,
      g_nSamplesMax,
      rAvg,
      dwMin,
      dwMax,
      (double) rStdDev);

   Dlg_AppendEditText(hwndEdit, szBuf);
   
   _tcscpy(szBuf, _TEXT("\r\n"));
   for (i = 0; i < g_nSamplesMax; i++) {
      _ultot(g_pdwTickSamples[i], szBuf + 2, 10);
      Dlg_AppendEditText(hwndEdit, szBuf);
   }

   // Move caret to start of text.
   Edit_SetSel(hwndEdit, 0, 0);

   // Make first report line first visible line.
   nVisLine = Edit_GetFirstVisibleLine(hwndEdit);
   Edit_Scroll(hwndEdit, -nVisLine, 0);

   // Enable updates, and force update.
   SetWindowRedraw(hwndEdit, TRUE);
   InvalidateRect(hwndEdit, NULL, TRUE);
}
Beispiel #5
0
void InterfaceUpdateAdmin()
{
	HWND hwnd;
	hwnd = GetDlgItem(HWND_ADMIN,IDC_ADMIN_RESPONSE);
	
	SetWindowRedraw(hwnd,FALSE);
	
	Edit_SetText(hwnd,admin_response_buf);
   SendMessage(hwnd, WM_VSCROLL, SB_BOTTOM, 0);
	
	SetWindowRedraw(hwnd,TRUE);
	InvalidateRect(hwnd,NULL,TRUE);
}
Beispiel #6
0
int ListBox_MoveStringUp(HWND hwndList, int nIndex)
{
    int nNewIndex;

    SetWindowRedraw(hwndList, FALSE);
    nNewIndex = ListBox_MoveString(hwndList, nIndex, -1, TRUE);
    ASSERT(nNewIndex != LB_ERR);
    if (ListBox_SetSel(hwndList, TRUE, nNewIndex) == LB_ERR)
    {
        // Try and use ListBox_SetCurSel() (for single selection listbox)
        ListBox_SetCurSel(hwndList, nNewIndex);
    }
    SetWindowRedraw(hwndList, TRUE);
    RedrawWindow(hwndList, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);

    return (nNewIndex);
}
VOID Dlg_PopulateModuleList(HWND hwnd) {

   HWND hwndModuleHelp = GetDlgItem(hwnd, IDC_MODULEHELP);
   ListBox_ResetContent(hwndModuleHelp);

   CToolhelp thProcesses(TH32CS_SNAPPROCESS);
   PROCESSENTRY32 pe = { sizeof(pe) };
   BOOL fOk = thProcesses.ProcessFirst(&pe);
   for (; fOk; fOk = thProcesses.ProcessNext(&pe)) {

      CToolhelp thModules(TH32CS_SNAPMODULE, pe.th32ProcessID);
      MODULEENTRY32 me = { sizeof(me) };
      BOOL fOk = thModules.ModuleFirst(&me);
      for (; fOk; fOk = thModules.ModuleNext(&me)) {
        int n = ListBox_FindStringExact(hwndModuleHelp, -1, me.szExePath);
         if (n == LB_ERR) {
            // This module hasn't been added before
            ListBox_AddString(hwndModuleHelp, me.szExePath);
         }
      }
   }

   HWND hwndList = GetDlgItem(hwnd, IDC_PROCESSMODULELIST);
   SetWindowRedraw(hwndList, FALSE);
   ComboBox_ResetContent(hwndList);
   int nNumModules = ListBox_GetCount(hwndModuleHelp);
   for (int i = 0; i < nNumModules; i++) {
      TCHAR sz[1024];
      ListBox_GetText(hwndModuleHelp, i, sz);
      // Place module name (without its path) in the list
      int nIndex = ComboBox_AddString(hwndList, _tcsrchr(sz, TEXT('\\')) + 1);
      // Associate the index of the full path with the added item
      ComboBox_SetItemData(hwndList, nIndex, i);
   }

   ComboBox_SetCurSel(hwndList, 0);  // Select the first entry

   // Simulate the user selecting this first item so that the
   // results pane shows something interesting
   FORWARD_WM_COMMAND(hwnd, IDC_PROCESSMODULELIST, 
      hwndList, CBN_SELCHANGE, SendMessage);

   SetWindowRedraw(hwndList, TRUE);
   InvalidateRect(hwndList, NULL, FALSE);
}
Beispiel #8
0
BOOL ListBox_DeleteAllStrings(HWND hwndListBox)
{
    BOOL bSuccess = FALSE;
    int iCount = ListBox_GetSelCount(hwndListBox);
    LPINT lpiItems = (LPINT)_alloca(iCount * sizeof(INT));
    ListBox_GetSelItems(hwndListBox, iCount, lpiItems);

    SetWindowRedraw(hwndListBox, FALSE);


    for ( ; iCount > 0; iCount--)
    {
        if (ListBox_DeleteString(hwndListBox, lpiItems[iCount - 1]) != LB_ERR)
            bSuccess = TRUE;
    }

    SetWindowRedraw(hwndListBox, TRUE);

    return (bSuccess);
}
Beispiel #9
0
void OnRefreshProcesses()
{
   HWND hwndList = GetDlgItem(g_hDlg, IDC_COMBO_PROCESS);
   SetWindowRedraw(hwndList, FALSE);
   ComboBox_ResetContent(hwndList);

   CToolhelp thProcesses(TH32CS_SNAPPROCESS);
   PROCESSENTRY32 pe = { sizeof(pe) };
   BOOL fOk = thProcesses.ProcessFirst(&pe);
   for (; fOk; fOk = thProcesses.ProcessNext(&pe)) {
      TCHAR sz[1024];

      // Place the process name (without its path) & ID in the list
      PCTSTR pszExeFile = _tcsrchr(pe.szExeFile, TEXT('\\'));
      if (pszExeFile == NULL) {
         pszExeFile = pe.szExeFile;
      } else {
         pszExeFile++; // Skip over the slash
      }

      StringCchPrintf(sz, _countof(sz), TEXT("%04u - %s"), pe.th32ProcessID, pszExeFile);
      int n = ComboBox_AddString(hwndList, sz);

      // Associate the process ID with the added item
      ComboBox_SetItemData(hwndList, n, pe.th32ProcessID);
   }
   ComboBox_SetCurSel(hwndList, 0);  // Select the first entry

   // Simulate the user selecting this first item so that the
   // results pane shows something interesting
   FORWARD_WM_COMMAND(g_hDlg, IDC_COMBO_PROCESS, 
      hwndList, CBN_SELCHANGE, SendMessage);

   SetWindowRedraw(hwndList, TRUE);
   InvalidateRect(hwndList, NULL, FALSE);
}
Beispiel #10
0
void FILETRANSFER::ChangeProtocol(HWND hDlg)
{
	int  index ;
	int  nCurProtocol = data0->fileType ;
	RECT rc ;

	index = (int)SendDlgItemMessage (
																		hDlg,
																		idProto,
																		CB_GETCURSEL,
	 																	0,
																		0L) ;
	if (index != nCurProtocol && index != LB_ERR)
		{
	  SetWindowRedraw(hDlg, FALSE);
		ShowProtocolFrame(
								hDlg, 
								protocolFrame[nCurProtocol].nFirstID,
		      			protocolFrame[nCurProtocol].nLastID, 
		      			FALSE);
    nCurProtocol = index ;
    ShowProtocolFrame(
    						hDlg, 
    						protocolFrame[nCurProtocol].nFirstID,
		      			protocolFrame[nCurProtocol].nLastID, 
		      			TRUE);
    SetWindowRedraw(hDlg, TRUE);
    GetWindowRect(
    							GetDlgItem(hDlg, DLG_FRAME),
						      &rc);
		MapWindowRect(NULL, hDlg, &rc);
		InvalidateRect(hDlg, &rc, TRUE);
		}
	ShowProtocolParam (hDlg, nCurProtocol) ;
	data0->fileType = nCurProtocol ;
}
VOID Dlg_PopulateProcessList(HWND hwnd) 
{
   HWND hwndList = GetDlgItem(hwnd, IDC_PROCESSMODULELIST);
   SetWindowRedraw(hwndList, FALSE);
   ComboBox_ResetContent(hwndList);

   CToolhelp thProcesses(TH32CS_SNAPPROCESS);
   PROCESSENTRY32 pe = { sizeof(pe) };
   BOOL fOk = thProcesses.ProcessFirst(&pe);

   /* Call function Process32Next for each process in the system */
   for (; fOk; fOk = thProcesses.ProcessNext(&pe)) 
   {
      TCHAR sz[1024];

      /* Place the process name (without its path) & ID in the list */
      PCTSTR pszExeFile = _tcsrchr(pe.szExeFile, TEXT('\\'));
      if (pszExeFile == NULL) 
	  {
         pszExeFile = pe.szExeFile;
      } 
	  else 
	  {
		 /* Skip over the slash */
         pszExeFile++; 
      }

      /* Append the code/resource integrity level and policy */
      DWORD dwCodeIntegrityLevel = 0;
      DWORD dwCodePolicy = TOKEN_MANDATORY_POLICY_OFF;
      DWORD dwResourcePolicy = 0;
      DWORD dwResourceIntegrityLevel = 0;

      TCHAR szCodeDetails[256];
      szCodeDetails[0] = TEXT('\0');

      TCHAR szResourceDetails[256];
      szResourceDetails[0] = TEXT('\0');

      if (GetProcessIntegrityLevel(pe.th32ProcessID, &dwCodeIntegrityLevel, 
         &dwCodePolicy, &dwResourceIntegrityLevel, &dwResourcePolicy)) {
         switch (dwCodeIntegrityLevel) {
            case SECURITY_MANDATORY_LOW_RID:
               _tcscpy_s(szCodeDetails, _countof(szCodeDetails), 
                  TEXT("- Low "));
               break;

            case SECURITY_MANDATORY_MEDIUM_RID:
               _tcscpy_s(szCodeDetails, _countof(szCodeDetails), 
                  TEXT("- Medium "));
               break;

            case SECURITY_MANDATORY_HIGH_RID:
               _tcscpy_s(szCodeDetails, _countof(szCodeDetails), 
                  TEXT("- High "));
               break;

            case SECURITY_MANDATORY_SYSTEM_RID:
               _tcscpy_s(szCodeDetails, _countof(szCodeDetails), 
                  TEXT("- System "));
               break;

            default:
               _tcscpy_s(szCodeDetails, _countof(szCodeDetails), 
                  TEXT("- ??? "));
         }

         if (dwCodePolicy == TOKEN_MANDATORY_POLICY_OFF) { // = 0
            _tcscat_s(szCodeDetails, 
               _countof(szCodeDetails), TEXT(" + no policy"));
         } else {
            if ((dwCodePolicy & TOKEN_MANDATORY_POLICY_VALID_MASK) == 0) {
               _tcscat_s(szCodeDetails, _countof(szCodeDetails), 
                  TEXT(" + ???"));
            } else {
               if ((dwCodePolicy & TOKEN_MANDATORY_POLICY_NO_WRITE_UP)
                  == TOKEN_MANDATORY_POLICY_NO_WRITE_UP) { 
                  _tcscat_s(szCodeDetails, _countof(szCodeDetails), 
                     TEXT(" + no write-up"));
               }

               if ((dwCodePolicy & TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN)
                  == TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN) { 
                  _tcscat_s(szCodeDetails, _countof(szCodeDetails), 
                     TEXT(" + new process min"));
               }
            }
         }

         switch (dwResourceIntegrityLevel) {
            case SECURITY_MANDATORY_LOW_RID:
               _tcscpy_s(szResourceDetails, 
                  _countof(szResourceDetails), TEXT("Low"));
               break;

            case SECURITY_MANDATORY_MEDIUM_RID:
               _tcscpy_s(szResourceDetails, 
                  _countof(szResourceDetails), TEXT("Medium"));
               break;

            case SECURITY_MANDATORY_HIGH_RID:
               _tcscpy_s(szResourceDetails, 
                  _countof(szResourceDetails), TEXT("High"));
               break;

            case SECURITY_MANDATORY_SYSTEM_RID:
               _tcscpy_s(szResourceDetails, 
                  _countof(szResourceDetails), TEXT("System"));
               break;

            case 0:
               _tcscpy_s(szResourceDetails, 
                  _countof(szResourceDetails), TEXT("Not set"));
               break;

            default:
               _tcscpy_s(szResourceDetails, 
                  _countof(szResourceDetails), TEXT("???"));
          }


         if (dwResourcePolicy == 0) { // = 0
            _tcscat_s(szResourceDetails, 
               _countof(szResourceDetails), TEXT(" + 0 policy"));
         } else {
            if ((dwResourcePolicy & TOKEN_MANDATORY_POLICY_VALID_MASK) == 0) {
               _tcscat_s(szResourceDetails, 
                  _countof(szResourceDetails), TEXT(" + ???"));
            } else {
               if ((dwResourcePolicy & SYSTEM_MANDATORY_LABEL_NO_WRITE_UP)
                  == SYSTEM_MANDATORY_LABEL_NO_WRITE_UP) { 
                  _tcscat_s(szResourceDetails, 
                     _countof(szResourceDetails), 
                     TEXT(" + no write-up"));
               }

               if ((dwResourcePolicy & SYSTEM_MANDATORY_LABEL_NO_READ_UP)
                  == SYSTEM_MANDATORY_LABEL_NO_READ_UP) { 
                  _tcscat_s(szResourceDetails, 
                     _countof(szResourceDetails), 
                     TEXT(" + no read-up"));
               }
               if ((dwResourcePolicy & SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP)
                  == SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP) { 
                  _tcscat_s(szResourceDetails, 
                     _countof(szResourceDetails), 
                     TEXT(" + no execute-up"));
               }
            }
         }
      }

      StringCchPrintf(sz, _countof(sz), TEXT("%s     (0x%08X)  %s    [%s]"), 
         pszExeFile, pe.th32ProcessID, szCodeDetails, szResourceDetails);
      int n = ComboBox_AddString(hwndList, sz);

      // Associate the process ID with the added item
      ComboBox_SetItemData(hwndList, n, pe.th32ProcessID);
   }

   ComboBox_SetCurSel(hwndList, 0);  // Select the first entry

   // Simulate the user selecting this first item so that the
   // results pane shows something interesting
   FORWARD_WM_COMMAND(hwnd, IDC_PROCESSMODULELIST, 
      hwndList, CBN_SELCHANGE, SendMessage);

   SetWindowRedraw(hwndList, TRUE);
   InvalidateRect(hwndList, NULL, FALSE);
}
Beispiel #12
0
BOOL File_OpenByDialog(HWND hwnd)
{
    TCHAR szFileName[MAX_PATH * 4] = _T("");
    FILEINFO fi;
    OPENFILENAME ofn;
    int nLineFeedType = CRLF_STYLE_AUTOMATIC;
    LPEDITVIEW lpew = MDI_GetEditView(NULL);

    if (lpew != NULL && lpew->lpes != NULL)
        nLineFeedType = TextBuffer_GetCRLFMode(lpew->lpes);

    Main_GetFileInfo(NULL, &fi);

    INITSTRUCT(ofn, TRUE);
    ofn.hwndOwner           = hwnd;
    ofn.hInstance           = g_hInstance;
    ofn.lpstrFilter         = String_MakeFilter(g_FilterSettings.szOpenFilter);
    ofn.nFilterIndex        = 1;
    ofn.lpstrFile           = szFileName;
    ofn.nMaxFile            = MAX_PATH;
    ofn.lpstrInitialDir     = (!(fi.dwFileType & FI_TYPE_MASK_EDIT) && fi.szFileName != NULL) ? Path_RemoveFileName(fi.szFileName): NULL;
    ofn.lpstrTitle          = _T("Open File(s)");
    ofn.Flags               = OFN_CREATEPROMPT | OFN_ENABLESIZING | OFN_EXPLORER | OFN_ALLOWMULTISELECT;// | OFN_ENABLEHOOK | OFN_ENABLETEMPLATE;
    ofn.lCustData           = (LPARAM)&nLineFeedType;
    ofn.lpfnHook            = File_OFNHookProc;
    ofn.lpTemplateName      = MAKEINTRESOURCE(IDD_OPENFILEDIALOG);

    if (GetOpenFileName(&ofn))
    {
        WIN32_FIND_DATA wfd;
        HANDLE hSearch;
        TCHAR szDirectory[MAX_PATH] = _T(""), szGluedFileName[MAX_PATH] = _T("");

        _tcscpy(szDirectory, szFileName);

        // Check if szDirectory actually exists (either file or directory)
        if ((hSearch = FindFirstFile(szDirectory, &wfd)) == INVALID_HANDLE_VALUE && !(_tcslen(szDirectory) && Path_HasRoot(szDirectory)))
        {
            return (FALSE);
        }
        else
        {
            FindClose(hSearch);

            // Stop redrawing while opening...makes the whole thing
            // a LOT faster...
            SetWindowRedraw(g_hwndMain, FALSE);

            // is szDirectory a directory?
            if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY || (_tcslen(szDirectory) == 3 && Path_HasRoot(szDirectory)))
            {
                LPTSTR psz = szFileName;

                //this means we have multiple files
                Path_VerifyBackslash(szDirectory, TRUE);
                _tcscpy(szGluedFileName, szDirectory);

                while (TRUE)
                {
                    int nLength = _tcslen(psz);

                    //copy and strip off
                    psz += nLength + 1;
                    if (*psz == _T('\0'))
                        break;

                    _tcscat(szGluedFileName, psz);
                    File_Open(szGluedFileName, nLineFeedType);
                    _tcscpy(szGluedFileName, szDirectory);
                }
            }
            else
            {
                // only one file so open it and leave
                File_Open(szDirectory, nLineFeedType);
            }

            //redraw again
            SetWindowRedraw(g_hwndMain, TRUE);
            RedrawWindow(g_hwndMain, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN);
        }

        return (TRUE);
    }

    return (FALSE);
}
Beispiel #13
0
/*
 * mswin_tw_wm_command() - WM_COMMAND handler for textwindows
 */
static void
mswin_tw_wm_command(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
    MSWIN_TEXTWINDOW *mswin_tw;

    mswin_tw = (MSWIN_TEXTWINDOW *)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_USERDATA);

    switch(id)
    {
    case IDM_FILE_CLOSE:
        DestroyWindow(hwnd);
        break;

    case IDM_FILE_PRINT:
        if(mswin_tw->print_callback)
            mswin_tw->print_callback(mswin_tw);
        break;

    case IDM_EDIT_COPY:
        SendMessage(mswin_tw->hwnd_edit, WM_COPY, 0, 0);
        break;

    case IDM_EDIT_CLEAR:
        mswin_tw_clear(mswin_tw);
        break;

    case IDM_EDIT_COPY_APPEND:
    {
        CHARRANGE cr;
        int text_len0, text_len1;
        HWND hwnd_edit = mswin_tw->hwnd_edit;
        BOOL EditIsReadOnly = Edit_ExIsReadOnly(hwnd_edit);

        SetWindowRedraw(hwnd_edit, FALSE);
        Edit_SetReadOnly(hwnd_edit, FALSE);

        // Get current selection.
        SendMessage(hwnd_edit, EM_EXGETSEL, (WPARAM)0, (LPARAM)&cr);

        // Get current length.
        text_len0 = Edit_ExGetTextLen(hwnd_edit, 0);

        // Paste current clip right before our new selection.
        Edit_ExSetSel(hwnd_edit, cr.cpMin, cr.cpMin);
        SendMessage(hwnd_edit, WM_PASTE, 0, 0);

        // Get new length.
        text_len1 = Edit_ExGetTextLen(hwnd_edit, 0);

        // Select new and old clip and copy em.
        Edit_ExSetSel(hwnd_edit, cr.cpMin, cr.cpMax + text_len1 - text_len0);
        SendMessage(hwnd_edit, WM_COPY, 0, 0);

        // Undo our paste and restore original selection.
        SendMessage(hwnd_edit, WM_UNDO, 0, 0);
        SendMessage(hwnd_edit, EM_EXSETSEL, (WPARAM)0, (LPARAM)&cr);

        // Set back to read only.
        Edit_SetReadOnly(hwnd_edit, EditIsReadOnly);
        SetWindowRedraw(hwnd_edit, TRUE);
        break;
    }

    case IDM_EDIT_SEL_ALL:
        Edit_ExSetSel(mswin_tw->hwnd_edit, 0, -1);
        break;
    }
}
Beispiel #14
0
/* This function locates the old signature in the specified edit
 * control and replaces it with the new one.
 */
void FASTCALL ReplaceEditSignature( HWND hwndEdit, char * pszOldSig, char * pszNewSig, BOOL fTop )
{
   LPSTR lpszOldSigText;
   LPSTR lpszNewSigText;
   UINT cbEdit;

   /* Get some lengths. Skip the replacement if
    * the signature is smaller than the edit text.
    */
   cbEdit = Edit_GetTextLength( hwndEdit );
   if( NULL != ( lpszOldSigText = GetEditSignature( pszOldSig ) ) )
      {
      if( NULL != ( lpszNewSigText = GetEditSignature( pszNewSig ) ) )
         {
         if( strlen(lpszOldSigText) <= cbEdit )
            {
            LPSTR lpText;
         
            INITIALISE_PTR(lpText);
            if( fNewMemory( &lpText, cbEdit + 1 ) )
               {
               DWORD sel;
               int nOldSig;
               int selEnd;
               int selStart;
         
               /* Get the edit control contents.
                */
               sel = Edit_GetSel( hwndEdit );
               selStart = LOWORD(sel);
               selEnd = HIWORD(sel);
               Edit_GetText( hwndEdit, lpText, cbEdit+1 );
               nOldSig = FStrMatch( lpText, lpszOldSigText, TRUE, FALSE );
#ifdef USEBIGEDIT
               SetWindowRedraw( hwndEdit, FALSE );
#endif USEBIGEDIT
               if( -1 != nOldSig )
                  {
                  Edit_SetSel( hwndEdit, nOldSig, nOldSig + strlen(lpszOldSigText) );
                  Edit_ReplaceSel( hwndEdit, lpszNewSigText );
                  }
               else
                  {
                  /* Not found, so go to end of edit text and append new
                   * signature there.
                   */
                  if( fTop )
                     Edit_SetSel( hwndEdit, 0, 0 );
                  else
                     Edit_SetSel( hwndEdit, 32767, 32767 );
                  Edit_ReplaceSel( hwndEdit, lpszNewSigText );
                  }
               Edit_SetSel( hwndEdit, selStart, selEnd );
#ifdef USEBIGEDIT
               SetWindowRedraw( hwndEdit, TRUE );
#endif USEBIGEDIT
               UpdateWindow( hwndEdit );
               FreeMemory( &lpText );
               }
            }
         FreeMemory( &lpszNewSigText );
         }
      FreeMemory( &lpszOldSigText );
      }
}
Beispiel #15
0
BOOL CAppBar::AppBar_SetSide(UINT uSide)
{
    
    if(!g_fAppRegistered)
        AppBar_Register();

    BOOL       fAutoHide = FALSE;
    // Calculate the size of the screen so we can occupy the full width or
    // height of the screen on the edge we request.
    m_rc.top = 0;
    m_rc.left = 0;
    m_rc.right = GetSystemMetrics(SM_CXSCREEN);   
    m_rc.bottom = GetSystemMetrics(SM_CYSCREEN);
    // Fill out the APPBARDATA struct with the basic information
    abd.cbSize = sizeof(APPBARDATA);
    abd.hWnd = pHandler;

    // If the appbar is autohidden, turn that off so we can move the bar
    if (m_pOptions->fAutoHide)
    {
        fAutoHide = m_pOptions->fAutoHide;

        // Turn off the redrawing of the desktop while we move things around.
        // If you put any breakpoints in this area you will lock up the desktop
        // Since turning off the desktop repaints turns it off for all the apps
        // in the system
        SetWindowRedraw(GetDesktopWindow(), FALSE);
        AppBar_SetAutoHide(FALSE);
    }

    // Adjust the rectangle to set our height or width depending on the
    // side we want.
    switch (uSide)
    {
     case ABE_TOP:
         m_rc.bottom = m_rc.top + m_pOptions->cyHeight;
          break;
        case ABE_BOTTOM:
          m_rc.top = m_rc.bottom - m_pOptions->cyHeight;
          break;
        case ABE_LEFT:
            m_rc.right = m_rc.left + m_pOptions->cxWidth;
           break;
        case ABE_RIGHT:
           m_rc.left = m_rc.right - m_pOptions->cxWidth;
           break;
    }
 
    // Move the appbar to the new screen space.
    AppBar_QuerySetPos(uSide, &m_rc, &abd, TRUE);

    // If the appbar was hidden, rehide it now
    if (fAutoHide)
    {
        AppBar_SetAutoHide(TRUE);

        SetWindowRedraw(GetDesktopWindow(), TRUE);
        RedrawWindow(GetDesktopWindow(), NULL, NULL, 
                  RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);         
    }

    return (TRUE);
}   
Beispiel #16
0
/* This function processes the WM_COMMAND message.
 */
void FASTCALL OutBasket_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify )
{
   switch( id )
      {
      case IDM_QUICKPRINT:
      case IDM_PRINT:
         CmdPrintOutbasket( hwnd );
         break;

      case IDD_HELP:
         HtmlHelp( hwnd, szHelpFile, HH_HELP_CONTEXT, idsOUTBASKET );
         break;

      case IDCANCEL:
         SendMessage( hwnd, WM_CLOSE, 0, 0L );
         break;

      case IDD_DELETE: {
         HWND hwndList;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         if( IsWindowEnabled( GetDlgItem( hwnd, id ) ) )
            if( fMessageBox( hwnd, 0, GS(IDS_STR253), MB_YESNO|MB_ICONINFORMATION ) == IDYES )
               {
               int cDeleted;
               int nCount;
               int nSel;
               int c;

               /* Set fIgnoreDeleteEvent because we could be
                * deleting lots of items, and we don't want each
                * deletion from the out-basket to be individual.
                */
               nCount = ListBox_GetCount( hwndList );
               SetWindowRedraw( hwndList, FALSE );
               cDeleted = c = 0;
               nSel = -1;
               fIgnoreDeleteEvent = TRUE;
               while( c < nCount )
                  {
                  if( ListBox_GetSel( hwndList, c ) > 0 )
                     {
                     OBINFO obinfo;
                     LPOB lpob;
         
                     lpob = (LPOB)ListBox_GetItemData( hwndList, c );
                     Amob_GetObInfo( lpob, &obinfo );
                     if( !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) )
                        {
                        ListBox_DeleteString( hwndList, c );
                        nSel = c;
                        Amob_RemoveObject( lpob, FALSE );
                        ++cDeleted;
                        --nCount;
                        }
                     else
                        ++c;
                     }
                  else
                      ++c;
                  }
               if( nSel >= nCount )
                  nSel = nCount - 1;
               SetWindowRedraw( hwndList, TRUE );
               if( cDeleted )
                  {
                  InvalidateRect( hwndList, NULL, TRUE );
                  UpdateWindow( hwndList );
                  if( nSel > -1 )
                     ListBox_SetSel( hwndList, TRUE, nSel );
                  Amob_SaveOutBasket( FALSE );
                  UpdateOutBasketStatus();
                  ShowOutBasketTotal( hwndOutBasket );
                  }
               fIgnoreDeleteEvent = FALSE;
               OutBasket_OnSetFocus( hwnd, NULL );
               }
         SetFocus( hwndList );
         break;
         }

      case IDD_HOLD: {
         HWND hwndList;
         int nCount;
         BOOL fFirst;
         BOOL fHold;
         int c;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         nCount = ListBox_GetCount( hwndList );
         fFirst = TRUE;                        
         fHold = FALSE;
         for( c = 0; c < nCount; ++c )
            if( ListBox_GetSel( hwndList, c ) )
               {
               OBINFO obinfo;
               LPOB lpob;
               RECT rc;

               lpob = (LPOB)ListBox_GetItemData( hwndList, c );
               Amob_GetObInfo( lpob, &obinfo );
               if( !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) )
                  {
                  if( fFirst )
                     {
                     if( obinfo.obHdr.wFlags & OBF_HOLD )
                        {
                        SetWindowText( GetDlgItem( hwnd, IDD_HOLD ), GS(IDS_STR281) );
                        fHold = FALSE;
                        }
                     else
                        {
                        SetWindowText( GetDlgItem( hwnd, IDD_HOLD ), GS(IDS_STR282) );
                        fHold = TRUE;
                        }
                     fFirst = FALSE;
                     }
                  obinfo.obHdr.wFlags &= ~OBF_ERROR;
                  if( fHold )
                     obinfo.obHdr.wFlags |= OBF_HOLD;
                  else
                     obinfo.obHdr.wFlags &= ~OBF_HOLD;
                  Amob_SetObInfo( lpob, &obinfo );
                  ListBox_GetItemRect( hwndList, c, &rc );
                  if( !IsRectEmpty( &rc ) )
                     InvalidateRect( hwndList, &rc, FALSE );
                  }
               }
         // !!SM!! 2.55.2035
         Amob_SaveOutBasket( FALSE );
         UpdateOutBasketStatus();
         ShowOutBasketTotal( hwndOutBasket );
         // !!SM!! 2.55.2035

         UpdateWindow( hwndList );
         SetFocus( hwndList );
         break;
         }

      case IDD_KEEP: {
         HWND hwndList;
         int nCount;
         BOOL fFirst;
         BOOL fKeep;
         int c;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         nCount = ListBox_GetCount( hwndList );
         fFirst = TRUE;
         fKeep = FALSE;
         for( c = 0; c < nCount; ++c )
            {
            if( ListBox_GetSel( hwndList, c ) )
               {
               OBINFO obinfo;
               LPOB lpob;
               RECT rc;

               lpob = (LPOB)ListBox_GetItemData( hwndList, c );
               Amob_GetObInfo( lpob, &obinfo );
               if( fFirst )
                  {
                  if( obinfo.obHdr.wFlags & OBF_KEEP )
                     {
                     fKeep = FALSE;
                     SetWindowText( GetDlgItem( hwnd, IDD_KEEP ), GS(IDS_STR319) );
                     }
                  else
                     {
                     fKeep = TRUE;
                     SetWindowText( GetDlgItem( hwnd, IDD_KEEP ), GS(IDS_STR318) );
                     }
                  fFirst = FALSE;
                  }
               obinfo.obHdr.wFlags &= ~OBF_ERROR;
               if( fKeep )
                  obinfo.obHdr.wFlags |= OBF_KEEP;
               else
                  obinfo.obHdr.wFlags &= ~OBF_KEEP;
               Amob_SetObInfo( lpob, &obinfo );
               ListBox_GetItemRect( hwndList, c, &rc );
               if( !IsRectEmpty( &rc ) )
                  InvalidateRect( hwndList, &rc, FALSE );
               }
            }
         // !!SM!! 2.55.2035
         Amob_SaveOutBasket( FALSE );
         UpdateOutBasketStatus();
         ShowOutBasketTotal( hwndOutBasket );
         // !!SM!! 2.55.2035

         UpdateWindow( hwndList );
         SetFocus( hwndList );
         break;
         }

      case IDD_LIST:
         if( codeNotify == LBN_SELCHANGE )
            {
            UpdateOutBasketStatus();
            break;
            }
         else if( codeNotify != LBN_DBLCLK )
            break;
         if( !IsWindowEnabled( GetDlgItem( hwnd, IDOK ) ) )
            break;

      case IDOK: {
         HWND hwndList;
         int nCount;
         int c;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         nCount = ListBox_GetCount( hwndList );
         for( c = 0; c < nCount; ++c )
            if( ListBox_GetSel( hwndList, c ) > 0 )
               {
               OBINFO obinfo;
               LPOB lpob;

               lpob = (LPOB)ListBox_GetItemData( hwndList, c );
               Amob_GetObInfo( lpob, &obinfo );
               if( Amob_IsEditable( obinfo.obHdr.clsid ) && !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) )
                  Amob_Edit( lpob );
               }
         break;
         }
      }
}
Beispiel #17
0
static void fillListBox(HWND hWnd, LPSTR lpszDir) 
{
  HWND hWndLB = GetDlgItem(hWnd, ID_LIST_DIR);
  HWND hWndTempLB = GetDlgItem(hWnd, ID_LISTTEMP_DIR);
  HWND hWndEdit = GetDlgItem(hWnd, ID_EDIT_DIR);
  if((hWndLB == NULL) || (lpszDir == NULL))
    return;
  
  int iLastChar = lstrlen(lpszDir);
  if(lpszDir[iLastChar - 1] == '\\')
    lpszDir[iLastChar - 1] = '\0';

  SetWindowRedraw(hWndLB, FALSE);
  ListBox_ResetContent(hWndLB);
  ListBox_ResetContent(hWndTempLB);

  LPSTR lpszLast;
  lpszLast = CharLower(lpszDir);

  SetWindowText(hWndLB, lpszDir);

  char szDir[_MAX_DIR];
  char szFullDir[_MAX_DIR];
  sprintf(szFullDir, "%s", lpszDir);
  sprintf(szDir, "%s\\*.*", lpszDir);

  BOOL bFirst = TRUE;
  char ch;
  int index;
  while (TRUE) 
  {
    LPSTR lpsz;
    if((lpszDir[0] == '\\') && (lpszDir[1] == '\\') && bFirst)
      lpsz = strchr(lpszLast + lstrlen(szUNCRoot), '\\');
    else
      lpsz = strchr(lpszLast, '\\');
    if(lpsz != NULL) {
      if (bFirst)
        ch = *(++lpsz);
      else
        ch = *lpsz;
      *lpsz = 0;
    } 
    else 
    {
      //If we're looking at a drive only, then append a backslash
      if (lpszLast == lpszDir && bFirst)
        lstrcat(lpszLast, "\\");
    }
    //Add the drive string--includes the last one where lpsz == NULL
    index = ListBox_AddString(hWndLB, lpszLast);

    UINT i = (NULL != lpsz) ? ID_ICON_FOLDEROPEN : ID_ICON_OPENSELECT;
    ListBox_SetItemData(hWndLB, index, MAKELONG(index, i));

    if(NULL == lpsz)
      break;

      //Restore last character.
    *lpsz = ch;
    lpsz += (bFirst) ? 0 : 1;

    bFirst=FALSE;
    lpszLast = lpsz;
  }
  int indent = index + 1;

  //Get available directories
  fillTempLBWithDirs(hWndTempLB, lpszDir);

  int itemCount = ListBox_GetCount(hWndTempLB);

  int i=0;
  for (i = 0; i < itemCount; i++) {
    index = ListBox_GetText(hWndTempLB, i, lpszDir);
    //Skip directories beginning with . (skipping . and ..)
    if(lpszDir[1] == '.')
      continue;
    //Remove the ending ']'
    iLastChar = lstrlen(lpszDir);
    lpszDir[iLastChar - 1] = '\0';
    //Add the string to the real directory list.
    index = ListBox_AddString(hWndLB, lpszDir + 1);
    ListBox_SetItemData(hWndLB, index, MAKELONG(indent, ID_ICON_FOLDERCLOSED));
  }
  //Force a listbox repaint.
  SetWindowRedraw(hWndLB, TRUE);
  InvalidateRect(hWndLB, NULL, TRUE);

  if(szFullDir[lstrlen(szFullDir) - 1] == ':')
    lstrcat(szFullDir, "\\");
  Edit_SetText(hWndEdit, szFullDir);

  GetScrollRange(hWndLB, SB_VERT, (LPINT)&i, (LPINT)&index);

  if(!(i == 0 && index == 0))
    ListBox_SetTopIndex(hWndLB, max((int)(index - 2), 0));

  ListBox_SetCurSel(hWndLB, indent - 1);
}
Beispiel #18
0
BOOL FileInterface_OpenFile_WithDialog(void)
{
    TCHAR szFileNames[MAX_PATH * 4] = _T("");
    OPENFILENAME ofn;
    LPFILEVIEW lpFileView;
    OPENSAVEFILEINFO osfi;

    lpFileView = FileInterface_GetFileView(MDI_GetActive(g_hwndMDIClient), FILE_FIND_BY_VIEW_HWND);

    osfi.dwFileType     = lpFileView->dwFileType;
    osfi.nLineFeedMode  = CRLF_STYLE_AUTOMATIC;

    INITSTRUCT(ofn, TRUE);
    ofn.hwndOwner           = g_hwndMain;
    ofn.hInstance           = g_hInstance;
    ofn.lpstrFilter         = String_MakeFilter(g_FilterSettings.szOpenFilter);
    ofn.nFilterIndex        = 1;
    ofn.lpstrFile           = szFileNames;
    ofn.nMaxFile            = MAX_PATH * 4;

    if (FILEISSOMETHING(lpFileView))
    {
        TCHAR szFileName;

        _tcscpy(szFileName, lpFileView->pszFileName);
        ofn.lpstrInitialDir = Path_RemoveFileName(szFileName);
    }
    else
    {
        ofn.lpstrInitialDir = (LPTSTR)NULL;
    }
    
    ofn.lpstrTitle          = String_LoadString(IDS_TITLE_OPENFILESDIALOG);
    ofn.Flags               = OFN_CREATEPROMPT | OFN_ENABLESIZING | OFN_EXPLORER | OFN_ALLOWMULTISELECT;// | OFN_ENABLEHOOK | OFN_ENABLETEMPLATE;

    if (lpFileView->dwFileType & FILE_TYPE_TEXT)
        osfi.nLineFeedMode  = PCP_TextEdit_GetCRLFMode(lpFileView->lpEditInterface);

    ofn.lCustData           = (LPARAM)&ofi;
    ofn.lpfnHook            = FileInterface_OFNHookProc;
    ofn.lpTemplateName      = MAKEINTRESOURCE(IDD_OPENFILEDIALOG);

    if (GetOpenFileName(&ofn))
    {
        if ((GetFileAttributes(szFileNames) & FILE_ATTRIBUTE_DIRECTORY) ||
            (_tcslen(szFileName) == 3 && Path_HasRoot(szFileNames)))
        {
            SetWindowRedraw(g_hwndMain, FALSE);

            Browse_HandleMultipleFileNames(szFileNames, (BROWSEMULTIPLEFILECALLBACK)FileInterface_OpenFile, (LPARAM)&osfi);

            SetWindowRedraw(g_hwndMain, TRUE);
            RedrawWindow(g_hwndMain, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN);
        }
        else
        {
            FileInterface_OpenFile(szFileNames, &osfi);
        }

        return (TRUE);
    }

    return (FALSE);
}