Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

SherTeks

@SherTeks
About
Posts
50
Topics
32
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How do I rename Outlook Pst newly created folder 'Personal Folders' programmatically ?
    S SherTeks

    Hi All, How do I rename a newly created pst folder 'Personal Folders' in Microsoft Outlook programmatically. Any script (vb OR VC++ COM, automation, etc.) or a bit of guidance would be helpful Thanks in Advance

    C / C++ / MFC tools question c++ com testing

  • How do I wrap text in Editbox?
    S SherTeks

    Hello, I have embedded an Edit box in my dialog during design time with styles 'Multiline', 'Horizontal Scroll' and 'Vertical Scroll'. During runtime, I set text to this edit box with SetWindowText. The set text extends the dimensions of the edit box and so I want the text to be wrapped dynamically. How could I achieve this ? Note : I also tried changing the styles to 'Auto HScroll', 'Auto VScroll', etc. Thanks in advance.

    C / C++ / MFC question wpf design hardware

  • How to get Error message string ?
    S SherTeks

    I have a DWORD value 1619. Corresponding error message to this value is : "This installation package could not be opened. verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid windows installer package" Is there a way (an API) which I could use to get the error message (as a string) by providing the DWORD value ? Thanks in advance

    C / C++ / MFC json help tutorial question

  • How do I check whether a share path exists?
    S SherTeks

    I know that a share path (say \\MycolleaguesmachineIP\\Ourshare\Projects ) exists. How do I determine that it does exist, programmatically. I came across NetShareEnum API but am not sure of its parameter values. Any help in this regard or any other alternative would be appreciated . Thanks in Advance

    C / C++ / MFC question json help

  • Why am I not able to get handle of file?
    S SherTeks

    Hello, I've a code snippet. Please follow the comments.

    	//Create a directory if it doesn't exist
    	if ( !PathFileExists("C:\\\\TestDir") )
    	{
    	CreateDirectory("C:\\\\TestDir", NULL);
    	}
    
    	//Create a batch file in the directory
    	CFile cfBatchFile( "C:\\\\TestDir\\\\TestBatch.bat", CFile::modeCreate| CFile::modeRead | CFile::modeWrite );
    
    	//Write 'C:\\\\windows\\\\system32\\cmd.exe" ipconfig>C:\\\\TestDir\\\\Test.txt in the batch file 
    	cfBatchFile.Write( "\\"C:\\\\windows\\\\system32\\cmd.exe\\" ipconfig>C:\\\\TestDir\\\\Test.txt", MAX\_PATH );
    
    	cfBatchFile.Close();
    
    	//ShellExecute runs "C:\\\\TestDir\\\\TestBatch.bat" and generates output for 'ipconfig' and redirects it to text file "C:\\\\TestDir\\\\Test.txt"
    	if ( ShellExecute(NULL, "open", "C:\\\\TestDir\\\\TestBatch.bat", NULL, NULL, SW\_HIDE) > (HINSTANCE)32)
    	{
    		CFile\* pcfTxt = NULL;
    
    		//Trying to open 'C:\\\\TestDir\\\\Test.txt' for reading BUT CRASH HAPPENS HERE (unhandled Exception)
    		pcfTxt = new CFile(\_T("C:\\\\TestDir\\\\Test.txt"), CFile::modeRead | CFile::shareDenyNone);
    
    		INT nLogTxtLen = pcfTxt->GetLength();
    	}
    

    In Debug mode (without a Debug point), the crash is shown at pcfTxt = new CFile(_T("C:\\TestDir\\Test.txt"), CFile::modeRead | CFile::shareDenyNone); But if I place a debug point at : pcfTxt = new CFile(_T("C:\\TestDir\\Test.txt"), CFile::modeRead | CFile::shareDenyNone); and then continue, no crash arises. I guess the issue is something to do with the handle of 'C:\\TestDir\\Test.txt' file. How could I rectify this. Is some Sleep() required to wait for the handle to be available. Replies would be appreciated. Thanks Edit/Delete Message

    C / C++ / MFC debugging help question

  • How do I redirect output of my console using PsExec?
    S SherTeks

    Thanks David. This works. Also found another option of using system() Thanks

    C / C++ / MFC question testing beta-testing tools

  • How do I redirect output of my console using PsExec?
    S SherTeks

    I'm using a remote execution tool called 'PsExec' from sysinternals. I use it this way in my command prompt : D:\Tools\Testing>psexec netsh firewall show opmode>D:\Log.txt This generates the output for 'netsh firewall show opmode' and redirects to D:\Log.txt Now, I implement the same logic/code in my application like this :

    CString csCmdLineParams = "netsh firewall show opmode>D:\\TestdwLog.txt";

    STARTUPINFO StartUpInfo;
    PROCESS_INFORMATION ProcInfo;

    DWORD ExitCode = -1;

    memset(&StartUpInfo, 0, sizeof(StartUpInfo));

    memset(&ProcInfo, 0, sizeof(ProcInfo));

    StartUpInfo.dwFlags = STARTF_USESHOWWINDOW;

    StartUpInfo.wShowWindow = SW_SHOW;

    CreateProcess( "C:\\windows\\system32\\cmd.exe", csCmdLineParams.GetBuffer(csCmdLineParams.GetLength() + ONE), NULL, NULL, NULL, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &StartUpInfo, &ProcInfo);

    WaitForSingleObject(ProcInfo.hProcess, INFINITE);

    GetExitCodeProcess(ProcInfo.hProcess, &ExitCode );

    if (ExitCode) {
    csCmdLineParams.ReleaseBuffer();
    CloseHandle(ProcInfo.hProcess);
    }

    csCmdLineParams.ReleaseBuffer();

    CloseHandle(ProcInfo.hProcess);

    But, I'm not able to redirect the output to D:\TestdwLog.txt. In fact the file is not created itself. Note : I do have administrator rights for my system. [required for PsExec] What am I doing wrongly ? I also tried StartUpInfo_IDI.dwFlags = STARTF_USESTDHANDLES; instead of StartUpInfo.dwFlags = STARTF_USESHOWWINDOW; Replies would be appreciated Thanks in advance.

    C / C++ / MFC question testing beta-testing tools

  • How do I know status of a service in a remote machine ?
    S SherTeks

    Thanks for the info. I'll try those.

    C / C++ / MFC question

  • How do I know status of a service in a remote machine ?
    S SherTeks

    Hello, How can I get the status of a service (Running, Stopped, etc) in a remote machine. I've the domain (of the remote machine) username and password. I need to get the status programmatically without using any tool. FYI : I'm using VC 6.0 Thanks in advance

    C / C++ / MFC question

  • How do I get the error message displayed on a console ?
    S SherTeks

    I've a third-party console application 'MyTestConsole.exe' that I launch by CreateProcess.

    STARTUPINFO StartUpInfo;
    PROCESS_INFORMATION ProcInfo;

    memset(&StartUpInfo, 0, sizeof(StartUpInfo));
    memset(&ProcInfo, 0, sizeof(ProcInfo));

    StartUpInfo.dwFlags = STARTF_USESHOWWINDOW;
    // StartUpInfo.wShowWindow = SW_HIDE;
    StartUpInfo.wShowWindow = SW_SHOWNORMAL;

    CreateProcess( "D:\\MyTestConsole.exe", NULL, NULL, NULL, NULL, CREATE_NEW_CONSOLE, NULL, NULL, &StartUpInfo, &ProcInfo);

    The console application launches successfully, but displays a standard windows error message, say for instance 'Error : could not open file' Now, how do I get the error string 'Error : could not open file' in a CString object. May be I'll have to use AttachConsole() and other console functions but not sure how. Pleae give your suggestions. Thanks in advance.

    C / C++ / MFC question help

  • How could I resolve this Problem Disabling a Menu item ?
    S SherTeks

    I have the following two classes : 1) A CDialog derived CDlgClass 2) A CCmdTarget derived CAnotherClass I am unable to disable an item of the launched context-menu. Please follow the comments below to track the problem.

    In DlgClass.cpp

    ON_COMMAND(ID_MENUITEM1, OnMenuItemEdit1Clicked)
    ON_UPDATE_COMMAND_UI(ID_MENUITEM1, OnUpdateMenuItemEdit1)

    //On Right-clicking the dialog, this function is called
    VOID CDlgClass::OnContextMenu(CWnd* pWnd, CPoint point)
    {
    //Here, another class' ShowContextMenu is called to load the menu and show it
    m_pAnotherClass->ShowContextMenu( this, point);
    }

    void CDlgClass::OnMenuItemEdit1Clicked()
    {
    //Control reaches here when menu item 1 is clicked
    }

    void CDlgClass::OnUpdateMenuItemEdit1(CCmdUI* pCmdUI)
    {
    //Control is expected to reach here before the menu launches but doesn't do so. Why?
    //I am expecting menu Item 1 to be disabled before it shows up.

    pCmdUI->Enable(FALSE);
    

    }

    In AnotherClass.cpp

    VOID CAnotherClass::ShowContextMenu(CWnd *pDlg, CPoint point)
    {
    CMenu cmCtxtMenu;

    cmCtxtMenu.LoadMenu(IDR\_MENU\_OPTIONS);
    	
    CMenu \*pcmPopupMenu = cmCtxtMenu.GetSubMenu(0);
    ASSERT(pcmPopupMenu);
    
    pcmPopupMenu->TrackPopupMenu (TPM\_RIGHTBUTTON|TPM\_LEFTALIGN, point.x, point.y, pDlg );
    

    }

    What could be the problem with disabling the menu item although I could actually activate the menu item handler properly? The function CDlgClass::OnUpdateMenuItemEdit1(CCmdUI* pCmdUI) itself is not getting called before launch of the menu, when the menu is loaded in a different class. What could be the reason ? Thanks in Advance.

    C / C++ / MFC c++ help question

  • How can I Fix the Crash caused due to change of User-defined message ?
    S SherTeks

    Thanks for the reply. The message was probably getting sent from one window to other bcoz the crash occurred after I clicked 'Ok' of one dialog and before the other dialog was launched. Defining WM_APP in lieu of WM_USER worked fixed the problem.

    C / C++ / MFC data-structures help question

  • How can I Fix the Crash caused due to change of User-defined message ?
    S SherTeks

    I've a user defined message defined as : #define UDM_TREEITEMCHECKBOX_CLICKED (WM_USER + 3) the handler is : LRESULT CTreePropSheet::OnTreeItemCheckBoxClicked(WPARAM wParam, LPARAM lParam) { -- } When I modify the user defined message as : #define UDM_TREEITEMCHECKBOX_CLICKED (WM_USER + 1) //(which is unique and no other user defined message is defined so) then, there is a crash in my application. A snippet of the call stack contents looks like this : For (WM_USER + 3) : (Successful case)

    TreePropSheet::CTreePropSheet::OnInitDialog() line 773
    CPropertySheet::HandleInitDialog(unsigned int 460026, unsigned int 460026) line 1209 + 14 bytes
    CWnd::OnWndMsg(unsigned int 272, unsigned int 460026, long 1452200, long * 0x0013f03c) line 1815 + 17 bytes
    CWnd::WindowProc(unsigned int 272, unsigned int 460026, long 1452200) line 1585 + 30 bytes
    AfxCallWndProc(CWnd * 0x0013f438 {TreePropSheet::CTreePropSheet hWnd=0x00080500}, HWND__ * 0x00080500, unsigned int 272, unsigned int 460026, long 1452200) line 215 + 26 bytes
    AfxWndProc(HWND__ * 0x00080500, unsigned int 272, unsigned int 460026, long 1452200) line 368
    AfxWndProcBase(HWND__ * 0x00080500, unsigned int 272, unsigned int 460026, long 1452200) line 220 + 21 bytes

    For (WM_USER + 1) : (Unsuccessful case)

    TreePropSheet::CTreePropSheet::OnTreeItemCheckBoxClicked(unsigned int 1, long 0) line 1148 + 14 bytes
    CWnd::OnWndMsg(unsigned int 1025, unsigned int 1, long 0, long * 0x0013e310) line 1815 + 17 bytes
    CWnd::WindowProc(unsigned int 1025, unsigned int 1, long 0) line 1585 + 30 bytes
    AfxCallWndProc(CWnd * 0x0013f438 {TreePropSheet::CTreePropSheet hWnd=0x001a0222}, HWND__ * 0x001a0222, unsigned int 1025, unsigned int 1, long 0) line 215 + 26 bytes
    AfxWndProc(HWND__ * 0x001a0222, unsigned int 1025, unsigned int 1, long 0) line 368
    AfxWndProcBase(HWND__ * 0x001a0222, unsigned int 1025, unsigned int 1, long 0) line 220 + 21 bytes

    Actually, in Successful case, the OnTreeItemCheckBoxClicked() is not required to be called (as is happening in Unsuccessful case) because the event (of clicking tree item) as such has not occurred at all.The crash arises before launch of my dialog (which contains the tree control) itself. Can the cause of the crash be figured out from the call stack contents ? It appears that third and fourth (or either) parameters of the following function is causing the problem AfxWndProcBase(HWND__ * 0x001a0222, unsigned int 1025, unsigned int 1, long 0) line 220 + 21 bytes Bu

    C / C++ / MFC data-structures help question

  • How do I copy the contents of a CListCtrl object ?
    S SherTeks

    I have a CListCtrl member in my dialog. During runtime, I fill the control's columns and rows with data using 'InsertColumn' and 'SetItemText' functions. Note : This List Control contains 5 rows and 3 columns full of data. Now, I want a copy of the data of the whole list control in another ClistCtrl object which I create during runtime using CListCtrl's Create function. How can I do this since I don't have a 'Copy' function as for data structures like CStringArray.

    C / C++ / MFC question

  • How can I remove an item in Combo box's list box ?
    S SherTeks

    Is it possible (and a rationale design) to show a menu on right-click of the list box item of a combo box and remove the item by clicking a menu item say 'Remove Item'. Any similar help material/article are welcome. Thanks in Advance.

    C / C++ / MFC question design help

  • How do I find the variable causing the memory leak ?
    S SherTeks

    I get a memory leak like this on debugging (after exiting the application): {1557} normal block at 0x00483160, 2 bytes long. Data: <1 > 31 00 How do I exactly find out the variable (name) holding the memory 0x00483160 that causes the leak. Note : Double-clicking on the aforementioned line doesn't show me the place of the memory leak Thanx in Advance.

    C / C++ / MFC question performance

  • How do I edit a combo box's list-box item in-place ?
    S SherTeks

    I've a dropdown combo box in a dialog. I want to right-click on a combox box's list box item and have the cursor placed at the start of the clicked item string for editing. How can I achieve this ? Any samples or relevant links would be appreciated. Thanks in advance.

    C / C++ / MFC question

  • How could I get the parent of an embedded control generically ?
    S SherTeks

    Correction : In my previous post, please consider m_CmbEditBox as of type CEditEx and not of type CEdit. My exact requirement is like this : On right-clicking the list box item the control reaches CListBoxEx::OnContextMenu. Please see the comment :

    void CListBoxEx::OnContextMenu(CWnd* pWnd, CPoint point)
    {
    /* The GetParent() here returns CTempWnd * (obtained while debugging).
    I am expecting the return pointer to be of type CSubClassedComboBox
    bcoz the subclassed combo box of type CSubClassedComboBox is the
    list box's parent */
    GetParent()->TestFn();
    }

    What am I doing wrong for list box bcoz the same mechanism for the child edit box of the CSubClassedComboBox works fine ie.

    void CEditEx::OnContextMenu(CWnd* pWnd, CPoint point)
    {
    /* The GetParent() here returns CSubClassedComboBox * (obtained while debugging) which is correct and is the expected result. */
    GetParent()->TestFn();
    }

    Is there anything to do with the temporary creation of the list box which is not the case with edit box ? If so, how could I acquire the desired result ? Thanks

    C / C++ / MFC docker hardware help question

  • How could I get the parent of an embedded control generically ?
    S SherTeks

    Thanks for your reply. May be I need to make my question a bit more clearer. Just assume that my dialog application has 2 controls : 1) a Combo Box and 2) another container control similar to combo box (but not exactly combo box). The common trait between the two controls is that they both embed the list box object derived from CListBoxEx. Now, I could right-click on any one list box at a particular point of time during run-time. The right-click would bring the control to the OnContextMenu of CListBoxEx::OnContextMenu. In this place, I should be able to identify the parent ie. either control 1) or 2) using GetParent(). But the only condition is that I shouldn't cast the pointer returned by GetParent() to any of the parent control pointers ie. GetParent()->TestFn() must call the TestFn() member function of the appropriate control of which the list box was right-clicked. Thanks

    C / C++ / MFC docker hardware help question

  • How could I get the parent of an embedded control generically ?
    S SherTeks

    I have a dialog-based application that contains a combo box. I've subclassed the combo box like this :

    HBRUSH CSubClassedComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {

      if (nCtlColor == CTLCOLOR\_EDIT)
      {
         //\[ASCII 160\]\[ASCII 160\]\[ASCII 160\]Edit control
         if (m\_CmbEditBox.GetSafeHwnd() == NULL)
            m\_CmbEditBox.SubclassWindow(pWnd->GetSafeHwnd());
      }
      else if (nCtlColor == CTLCOLOR\_LISTBOX)
      {
    
         //ListBox control
    	  if (m\_CmbListBox == NULL)
    	  {
    		  m\_CmbListBox = new CListBoxEx;
    
    		  if (m\_CmbListBox->GetSafeHwnd() == NULL)
    		  {			  
    			  m\_CmbListBox->SubclassWindow(pWnd->GetSafeHwnd());
    		  }
    	  }
      }
    
    HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
    
    return hbr;
    

    }

    m_CmbEditBox and m_CmbListBox are objects of CEdit and CListBoxEx(derived from CListBox) respectively and declared in SubClassedComboBox.h as the class CSubClassedComboBox's members. During run-time of my application, I pull down the list box and right-click on any of the list box items. My control reaches here :

    void CListBoxEx::OnContextMenu(CWnd* pWnd, CPoint point)
    {
    GetParent->TestFn();
    }

    Now, in CListBoxEx::OnContextMenu, I want to call a member function ( say TestFn() ) available in class CSubClassedComboBox. Please see the following code :

    void CListBoxEx::OnContextMenu(CWnd* pWnd, CPoint point)
    {
    ((CSubClassedComboBox *)GetParent())->TestFn(); //This works and TestFn() of CSubClassedComboBox is called

    GetParent())->TestFn();		//But this doesn't work
    

    }

    As in the comments, the second statement doesn't work. I don't want to cast the pointer returned by GetParent() to CSubClassedComboBox * bcoz this wouldn't be in generic sense. By this, I mean to say that GetParent() should be able to give the parent pointer which is CSubClassedComboBox * in this case, but could be anything else (eg. another container window that contains the CListBoxEx object). In summary, GetParent()->TestFn(); should call TestFn() of CSubClassedComboBox as per the requirement above. But GetParent())->TestFn(); should be able to call TestFn() of say CSubClassedSomeContainerWindow if m_ListBox is a member of CSubClassedSomeContainerWindow So, I am looking for a solution that is generic, to find the parent. Any help would be appreciated. Thanks in advance.

    C / C++ / MFC docker hardware help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups