|
Chris Losinger wrote:
so i can see how coming from iostreams to C I/O would seem ugly and primitive
Damn straight !!!
Chris Losinger wrote:
from the other direction, iostreams seems fluffy and prissy.
I guess so. And I guess I'm a hypocrite for decrying C# as too prissy in favour of C++, but in the end, it's all the same, we're all creatures of habit, aren't we ?
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
You know, just recently I did use your iostream article to read and write to a richtextbox which was giving me garbage when done with fread. Then I totally forgot about it, since I dont do too much of file IO. Thanks for the reminder. Wont hurt to re-read the article again either
Thanks,
ns
|
|
|
|
|
I'm making a W32 image viewer dialog and I resize the window according to each picture dimension.
I've got a problem with the scroll bars as their dimension is part of the client area. Thus I have to get the Horz. ScrollBar width in order to resize correctly.
I would also need to know if the scroll bar is visible or not in order to hide/show it only when necessary.
I found the GetScrollInfo and GetScrollBarInfo that could help me solve those 2 problems but they only are an indirect way to get the informations I need.
Is there a better API way to:
- Get the width/Height of a scroll bar
- Know if a scrollbar is shown/Hidden
The answer would probably be the same under MFC but I can't make a MFC dialog for thsi project.
Thanks
|
|
|
|
|
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
|
|
|
|
|