|
Yarp wrote:
I've got a problem with the scroll bars as their dimension is part of the client area.
If you're just using WS_HSCROLL/VSCROLL, the scrollbars are not part of client area.
Use GetSystemMetrics to get the scrollbar height/width.
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
Hi Tomasz, I just found your reply today while lurking through this forum. THnak you for your reply. Fortunately I recalled the GetSystemMetrics function this week end but I'm still very intersted by your answer.
Yes, I'm just using those 2 styles, and that's true they are not part of the client area - there's a not missing here. Is there any style that would include the scroll bar size within the client area ?
Yarp
http://www.senosoft.com/
|
|
|
|
|
yarp wrote:
Is there any style that would include the scroll bar size within the client area ?
No. If you need scrollbars *within* client area, then you have to abandon WS_HSCROLL/WS_VSCROLL and place scrollbar controls yourselft. Note that this will require repositioning them in WM_SIZE.
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
Ok, then I can live with the WS_*SCROLL scroll styles. Adding a scrollbar control would be of no benefit to me.
I was very surprised last week when after resizing my client area I found it had the proper size minus the H. scroll bar width. All is clear now. I'm a Borland CBuilder programmer at the origin - now moving to MSVC - that's why I've still a lot to learn about the GUI API.
... and that's why I need a W32 Window, my project is still half CBuilder, a quarter MFC, a quarter W32. Very Interesting too to mary those techniques but somtimes a bit messy
Thanks
Yarp
http://www.senosoft.com/
|
|
|
|
|
GetSystemMetrics() SM_CXHSCROLL, SM_CYHSCROLL, SM_CXVSCROLL, SM_CYVSCROLL will tell you the dimensions of the scrollbars.
In ED I keep my own flag which tracks whether a scrollbar is visible or not. However these are scrollbar controls as they are used in splitter windows and you are probably using the windows builtin scrollbars.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
anyone knows a good stress test application ?
to find
memory leaks
resource leaks
etc...
Casa.Sapo.pt
|
|
|
|
|
You can use my product MemWatcher[^] to monitor memory and resource usage, and stress RAM.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi.
I would like to know a way to correctly cast a string object to LPSTR.
I have an LVITEM structure for a CListCtrl.
-----
string szText = "testing 1 2 3";
LVITEM item;
...
// Compiler does not allow this kind of typecasting.
// Note "testing 1 2 3" alone is not an option. I can
// use a string and/or CString object or allocated
// new memory and then copy the data from szText.c_str()?
item.pszText = szText;
-----
How do you get the line above to work? I have tried using a CString object, but the compiler kept responding with an error about LPSTR.
Thanks,
Kuphryn
|
|
|
|
|
item.pszText = (LPSTR)(LPCTSTR) szText;
or
item.pszText = szText.GetBuffer(0);
And I swallow a small raisin.
|
|
|
|
|
You cannot. std::string does not have a method to get a non-const pointer to the data. Use a CString and GetBuffer().
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Okay. Thanks everyone.
Kuphryn
|
|
|
|
|
I saw members recommending CString.GetBuffer() and double casting (LPSTR)(LPCTSTR)(CString). Is there any advantage to using GetBuffer() and/or casting?
Kuphryn
|
|
|
|
|
Do the following:
item.pszText = myCString.GetBuffer(iWhateverSizeIsNeeded);
myCString.ReleaseBuffer();
or
item.pszText = (LPSTR)(LPCTSTR)myCString;
if you're looking for trouble.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
kuphryn wrote:
(LPSTR)(LPCTSTR)(CString)
That code is patently wrong. The fact that it compiles (because the casts override type checking) and that it even runs (because the buffer just happens not to be modified) does not make the code correct. Sure, it may work in the first situation you try it, but if you make a habit of doing so, it'll eventually break with some other API and you'll be stumped as to why the code "suddenly doesn't work".
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Okay. Thanks everyone.
I will use CString.GetBuffer() and CString.ReleaseBuffer().
Kuphryn
|
|
|
|
|
I am using EnumWindows to enumerate all windows till it finds my target window (which in this case is an instance of IEXPLORE.exe, Internet Explorer). Once found I use the Handle to the window and then do ShowWindow( hwnd, SW_HIDE).
My routine works for all targets/applications I have tested so far except for Internet explorer. I manage to find the window, but when I issue the ShowWindow(SW_HIDE) for it nothing happens. The browser just stands there and stares at me.
Any ideas?
Thanks
|
|
|
|
|
Can you MoveWindow() the window? If so, you could try moving it to (-32767,-32767) in lieu of hiding it.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Well apparently the reason it does not work is that I am creating an Instance of IE using CreateProcess. I retain the processID, which I then use to find the HWND using EnumWindows. Apparently the HWND that I obtain is not that of what we see as IE. I tried something similar to what you suggested, I did SW_MAXIMIZE instead of SW_HIDE and the entire screen became white. Obviously another window that I maximized. So IE is probably run through another parent process the window to which is always hidden (and the handle to which I get from EnumWindows) or something like that. What a pain!!!!!
So now I need a way to find the HWND for the main IE window that we see and use. Any suggestions?
Thanks,
Ranjan
|
|
|
|
|
Ugh, that's nasty.
Off the top of my head, the only cheesy solution I can think of is to use EnumWindows() to find all top level windows, and check the caption of each for "Microsoft Internet Explorer" (of course this won't work on non-English systems). For every match, get the process id to which the window's thread belongs and see if it matches the saved process id. I'd have to investigate to see how to do that last part. Sorry, I know I'm not being too helpful!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
When I used debug version, it is OK, but when I used release version, there is always a mistake to take place: the instruction at "0x0000004e" referenced memory at "0x0000004e". The memory could not be "read". I do not know what is wrong with it.
I also encountered such problem before.
Please help me!!!!!! Otherwise I will die
|
|
|
|
|
If you are using windows strucs it is a good idea to make a "ZeroMemory" first
Casa.Sapo.pt
|
|
|
|
|
|
I read the article you recommend and thought it should be a unitializated problem. But I check the code and can not find where it come from.
Following is the code which the problem come from.
CString FileName;
int nCount;
// check whether only one item hit by mouse
// if not, return
if((m_locallist.GetSelectedCount())!=1)
{
MessageBox("Please select one file","Error", MB_OK);
return;
}
// get click position
POSITION pos = m_locallist.GetFirstSelectedItemPosition();
// get item index and name clicked
nCount = m_locallist.GetNextSelectedItem(pos);
FileName = m_locallist.GetItemText(nCount, 0);
// if it is a directory, change current directory
// and show files in this directory again
if(m_locallist.GetItemText(nCount,0) == "..")
{
chdir("..");
char lpBuffer[80];
GetCurrentDirectory(80, lpBuffer);
m_locallist.DeleteAllItems();
m_local.DisplayDir(m_locallist, lpBuffer);
}
else{
CFileFind finder;
// start working for files
char File[100];
char dir[80];
GetCurrentDirectory(80, dir);
sprintf(File,"%s\\%s", dir, FileName);
BOOL bWorking = finder.FindFile(File);
finder.FindNextFile();
if(!finder.IsDots()){
if(finder.IsDirectory())
{
m_locallist.DeleteAllItems();
chdir(FileName);
// GetCurrentDirectory(80, dir);
m_local.DisplayDir(m_locallist, File);
}
}
finder.Close();
}
|
|
|
|
|
Well there are some obvious problems which jump out at me.
First:
david fox wrote:
char lpBuffer[80];
GetCurrentDirectory(80, lpBuffer);
Will trash memory whenever the current directory is >= 80 characters. This is because you aren't leaving room for the terminating '\0' in the string. I'd recomend never using hard coded sizes like 80 in function calls. Instead use sizeof( whatever )-1. You should really be using _MAX_PATH here anyway.
david fox wrote:
sprintf(File,"%s\\%s", dir, FileName);
is another disaster waiting to happen. Who says 'dir + Filename' will fit into File?
Not testing the success or otherwise of functions like chdir(), GetCurrentDirectory() etc. is also bad practice.
If you build your release code with Debug info, you can simply jump into the debugger and see precisely where the error is. I'm sure that's mentioned in the article I mentioned.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
david fox wrote:
CString FileName;
...
char File[100];
Why are you mixing char* and CString so heavily?
Most things can be done with CString (use ist buffer-access functions).
And all you buffers (char* and those that you take from CString) should really be of size _MAX_PATH !
Hope this helps
|
|
|
|