Thanks. That was a very useful add-in.
caykahve
Posts
-
line count -
line countHello, I'm using MS Visual Studio .NET 2003. how can I get the total line count of the whole project? Thanks in advance
-
How to save CBitmap to fileHello, I need to make a *.bmp file out of my CBitmap file. I do not know about bitmaps so much and i cannot make conversions between different types. Can someone help me? Thanks in advance
-
Problems with destroying a dialog boxI create another dialog box from my main dialog box. I want to show it and remove it when i want, without the user's will. I call the show function and the remove function from different places, and 90% I am able to remove it. For the other 10% I tried calling DestroyWindow() to remove, or calling it in the class destructor. I also tried overriding PostNcDestroy() and calling CDialog::PostNcDestroy() inside, etc. OnDestroy(), PostNcDestroy() and OnNcDestroy() are called respectively, but I keep seeing the dialog box, it is not removed. Can someone please help me? How can I destroy it properly? Thanks in advance To show:
pOtherBox = new COtherBox(); BOOL ret = pOtherBox->Create(IDD_OTHERBOX, this); pOtherBox->SetWindowPos(&this->wndTopMost, left,top,width,height, SWP_NOREPOSITION|SWP_NOSENDCHANGING|SWP_NOACTIVATE|SWP_SHOWWINDOW);
To remove:if(pOtherBox!=NULL) { delete pOtherBox; //pOtherBox->DestroyWindow(); //also tried instead of delete pOtherBox = NULL; }
-
OnLButtonDown cannot catch mouse click on CButtonHi, I use OnLButtonDown and OnLButtonUp because I want to control the left mouse button press and release over more than one button at the same time. However, if I click on the empty area of the dialog I get these functions called, while I cannot get them called when I click on the buttons themselves. :doh: There is no OnBnClickedButton..() function called. Do I have to change the properties of the buttons? Thanks in advance
-
moving controls on a dialog dynamicallyThank you. That helped. caykahve
-
moving controls on a dialog dynamicallyHi, I have a dialog based application on which I have a tab control made of dialogs. On the tab pages I have some controls. I want to move some of these controls dynamically. The control's start coordinates seen from the resource view are (7,3), which should be seen as left:7,top:3 from a CRect type. I see some strange behaviour with the below codes (called from CTab1Dlg class member functions): Test 1:
CRect rect; GetDlgItem(IDC_STAT1)->GetClientRect(&rect); // start point is (0,0) here GetDlgItem(IDC_STAT1)->MoveWindow(&rect); UpdateData(false);
afterwards the control moves to the left and upwards. Test 2: If I put this line before MoveWindow() line above, then the control still moves to left and upwards, but this time a little.rect.OffsetRect(7,3);
Test 3: If I change the inputs to (11,5), then the position does not change:rect.OffsetRect(11,5);
Test 4: If I try to get the coordinates of the tab's dialog then I get an access violation when i try to reach its members:GetDlgItem(IDD_TAB1)->GetClientRect(&rect);
I want to shift the controls upwards and downwards dynamically. How can I get the correct initial coordinates? thanks in advance -
Cannot enumerate with EnumWindowsActually I do it as told in Joseph Newcomer's article (http://www.codeproject.com/cpp/callbacks.asp?msg=27622) And the CWnd is retrieved by CWnd::FromHandle(). Why is that a problem?
-
Cannot enumerate with EnumWindowsHi, After starting some certain applications with ShellExecuteEx() function and getting their process handles in return, on some other event I want to get the CWnd handle to those windows and bring them to the front and resize, for which I use SetWindowPos. How I try to get the mentioned CWnd handle: - After starting the application, I get the process ID with
OpenedThreadPID = GetProcessId(ProcessHandle);
- Then I call EnumWindows function - and then in the callback function I check the called window's process ID withGetWindowThreadProcessId(pWnd->m_hWnd,&FoundThreadPID); if(FoundThreadPID == OpenedThreadPID) SearchedCwnd = pWnd;
- Then I useSetWindowPos(&SearchedCwnd->wndTopMost,StartX,StartY,Width,Height, SWP_NOREPOSITION|SWP_NOSENDCHANGING|SWP_NOZORDER|SWP_SHOWWINDOW );
The callback function is not called. What am I doing wrong? BTW, can I also reach the windows minimized to tray? Any help appreciated. Thanks in advance Caykahve -
Back slashes '\' and SHGetSpecialFolderPathThank you very much, that works. Regards
-
Back slashes '\' and SHGetSpecialFolderPathI see that it works with your code, but not with the code I have, which is similar to yours (see my initial message). I don't understand. Thanks and regards
-
Back slashes '\' and SHGetSpecialFolderPathWhen the string has a backslash it acts differently. I know that to add a quotation mark, you need a backslash in front of it. CString::Insert and CString::operator + act different when there is a backslash in the CString object. I'm sorry to say that I could not get a result with the code you sent either. Regards -- modified at 7:48 Monday 29th August, 2005
-
Back slashes '\' and SHGetSpecialFolderPathI do not want to put quotation marks to both ends of the text. I want to convert a string (i.e. CString) like C:\Program Files to C:\\Program Files - which is doubling the back slashes... Regards
-
Back slashes '\' and SHGetSpecialFolderPathIt's not my application actually.. There might be several applications whose "theApp" I don't have.
-
Back slashes '\' and SHGetSpecialFolderPathHi, I have a problem with using a path. I have to obtain the program files' path programatically, therefore I use this function.
// Get Program Files Path
CString PFPath;
SHGetSpecialFolderPath(NULL,PFPath.GetBuffer(_MAX_PATH),CSIDL_PROGRAM_FILES, FALSE);
MessageBox(PFPath);and the message box says: C:\Program Files I need to add something at the end of this string and then i try to use it in another function which needs the paths in double back slashes like: "C:\\Program Files" Then I try to do a conversion in PFPath in order to double the backslashes to change from "C:\Program Files" to "C:\Program Files"
// double
int i=0;
i = PFPath.Find("\\",i);
while( i>-1 )
{
CString found;
found.Format("Backslash found at index: %d",i);
MessageBox(found);
//Insert a \ in front of the found one to double it
PFPath.Insert(i,(CString)"\\");
MessageBox(PFPath);
//Get the next one
i += 2;
i = PFPath.Find("\\",i);
}
if(i==-1)
MessageBox("No more backslashes");
MessageBox(PFPath);The message box output of this path is: Backslash found at index: 2 \ No more backslashes \ As seen, the insert function turned the whole string into a single backslash instead of inserting one.
// extend the path
CString WholePath = PFPath + (CString)"\\some_folder\\myfile.exe";
SHELLEXECUTEINFO shellInfo;
...
shellInfo.lpFile = WholePath;
::ShellExecuteEx(&shellInfo);The conversion cannot be done properly, and shellInfo.lpFile needs double slashes. Therefore ShellExecuteEx cannot receive the path. I have also tried the '\' conversion issue with
CString::Replace
;CString::left, CString::Right
and concetanation with operator+
. Now I'm almost convinced that it is not possible to do it with the CString class. :confused: Is there any other way to convert the '\' to '\\'? Regards and thanks in advance, Caykahve -- modified at 5:49 Monday 29th August, 2005 -
how to insert a back slash \ in a stringC:\folder is actually is not a user input, it is
// Get Program Files Path SHGetSpecialFolderPath(NULL,PFPath.GetBuffer(_MAX_PATH), CSIDL_PROGRAM_FILES, FALSE);
and it gets "C:\Program Files" exactly. I add something at the end of this string and then i try to use it inCString WholePath = PFPath + (CString)"\\....\\file.exe; SHELLEXECUTEINFO shellInfo; ... shellInfo.lpFile = WholePath; ::ShellExecuteEx(&shellInfo);
If I do not use double slash, I get the error: "The program cannot find the file specified" That's why I need double slash. Why is it so hard to insert the required character in to a string I don't understand. :sigh: Is there some other way to obtain "C:\\Program Files"? -
how to insert a back slash \ in a stringOK, you are right. But still the insert function does not work properly. Here is the changed code snippet:
int i=0; i = PFPath.Find("\\",i); while( i>-1 ) { CString found; found.Format("Backslash found at index: %d",i); MessageBox(found); PFPath.Insert(i,(CString)"\\"); MessageBox(PFPath); i += 2; i = PFPath.Find("\\",i); } if(i==-1) MessageBox("not found"); MessageBox(PFPath);
Output: Backslash found at index: 2 C:\folder1 \ not found \ -
how to insert a back slash \ in a stringI already tried replacing the "\" with "\\". the program can be compiled, but the result is erroneous: Then i have at the beginning of the snippet PFPath: "C:\folder1\folder2" and PFPath: "\" at the end of the snippet. I don't have '.' normally, it was "\". It's a typo that occurred during copying here to the messageboard.
-
how to insert a back slash \ in a stringI don't know how deep the first path exactly. To be more precise, i can add my code here:
// Here I have PFPath as "C:\folder1\folder2" int i=0; while( PFPath.Find("\",i)!=-1 ) { PFPath.Insert(i,(CString)".\"); i+=2; } // Here I want to have PFPath as "C:\\folder1\\folder2"
:confused: -
how to insert a back slash \ in a stringHi, I get a path like "C:\folder" in my program. And I want to use it in a function which needs "C:\\folder". I wanted to use CString::Insert() function, but I got the error message 'new line in constant' when I use this: "\" How can I insert a \ in a string? Thanks in advance caykahve