|
Use LB_INSERTSTRING to add items to the control or make sure the
control doesn't have the LBS_SORT style and use LB_ADDSTRING.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am writing codes in SDI (MFC 7.0) with 1 document and multiple views (only 1 view active at one time). The parent window's size is fixed (cx = 1024 and cy = 768 from CMainFrame::PreCreateWindow). There are no max/min/close buttons on the upper right of the title bar. No resize either. And now, I have different views derived from CFormView. These views have different sizes (350 x 200, 550 x 400, 900 x 600). I just want all the views to be 1010 x 700 in size dynamically when they are called (i.e. 350 x 200 -> 1010 x 700, 550 x 400 -> 1010 x 700, 900 x 600 -> 1010 x 700). How do I accomplish this? The parent window contains four parts: title bar, menu, client window (will be filled up by one of the formviews), and status bar. By the way, I do know how to switch views. Please help. Thank you for your time.
|
|
|
|
|
MFC usually takes care of this for you. By default, views are sized to take up
the client area not occupied by decorations (toolbar, status bar, etc.). If you
want this behavior, and you're not getting it, maybe try calling RecalcLayout()
on the parent frame after setting the active view.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Thanks for the reply.
If I insert the RecalcLayout() inside the OnInitialUpdate of
the View then the outer frame window will shrink into the
size of the view. What I want is the size of the view needs
to grow as the outer frame window grows (actually the outer frame
has been set to fixed values cx and cy). The reason for this effect
is I want to populate each view dynamically with controls such as
buttons, datagrid, textboxes, list boxes, and combo boxes. Please
help. Thank you for your time. Have a nice day.
|
|
|
|
|
Call ResizeParentToFit (true) after calling RecalcLayout
Judy
|
|
|
|
|
Just a comment.
Am I missing something here?
The view frame is resized to fit the variable size of parent.
The parent size is subsequently changed.
So why RecalcLayout does not do the job by itself?
BTW Judy - your suggestion is now in my project notes.
Good one.
Thanks
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: Am I missing something here?
The view frame is resized to fit the variable size of parent.
The parent size is subsequently changed.
So why RecalcLayout does not do the job by itself?
At a guess, because RecalcLayout only affects the frame window i.e. CMainFrame. Calling it implies that the frame size has changed and the scroll bars need to be adjusted to the new size, but there is no relation, with respect to this call itself, between the view and the frame. The call to ResizeParentToFit calculates what an appropriate client size should be and then tells the frame what it's new size should be.
From MSDN description of CScrolView::ResizeParentToFit
ResizeParentToFit assumes that the size of the view window has been set. If the view window size has not been set when ResizeParentToFit is called, you will get an assertion. To ensure that this does not happen, make the following call before calling ResizeParentToFit:
GetParentFrame()->RecalcLayout();
Judy
|
|
|
|
|
I meant call RecalcLayout() when you change views, not from OnInitialUpdate().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Thanks for the clarification. Much appreciated. I will try it.
|
|
|
|
|
How to change sid of a disk using mfc, after cloning the disk.
|
|
|
|
|
Hello guys I'd like to ask a question...
I've written a simple client/server app using visual c++ 6 and winsock2 libraries;
the sockets are message-based. I created some common structures to separate the information I want to to be sent; In the receiving phase I managed to select the struct from the incoming data according the to the received bytes, but due to packet fragmentation obviously the struct is not received in one block, but in 2,3 or 4 fragments (the struct's size is about 3600 bytes).
so my question is: how can I gather all the fragments of the incoming data to a unique buffer, in order to cast them to the struct and get the data?
I need a little help because I'm confused about the functions I should use to do this (strcat, memset??)
thanks in advance to anybody is going to help
|
|
|
|
|
deerhunter89 wrote: the sockets are message-based
You state "TCP" in the thread topic but you say the sockets are message based.
If you're using TCP then your sockets are stream based.
That means the protocol stack knows nothing more than a stream of bytes.
Since you've added your own message based protocol on top of TCP, it's
up to you to know how many bytes to receive to reassemble a "message".
I personally prefer to receive just the number of bytes I'm expecting for a given "message".
If it doesn't all come in one recv() call, then I keep an offset and number-of-bytes-remaining
variable to know how many bytes to receive on the next call and where to put them.
This eliminates double-buffering - receiving into a buffer and then assembling into another
buffer. By tracking the number of bytes remaining for a given message, and only receiving
the number of bytes expected, it also eliminates the need to store bytes that are meant for the
next "message".
Anyway, the str___() functions aren't much use unless your messages are NULL-terminated strings.
If your messages are all ASCII, I suppose you could use the strn___() functions.
For binary data, binary copy functions are a better choice - memcpy(), CopyMemory(), etc.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm trying to mimic the pipe capability of a unix command line in windows(2003 Ent. Ed).
btw - SUA 5.x does not let me execute this shell script the same way. The pipe is locked!
My unix shell script executes the following:
~~~~~~~~~~~~~~~~~~start~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mknod exp_pipe_dmp p
exp user/passwd@SID parfile=mydb.par &
gzip < exp_pipe_dmp > exp_sid.dmp.gz
~~~~~~~~~~~~~~~~~~~end~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Exp is an oracle command-line utility to create a database dump file(binary).
We execute the exp command in the background then immediately redirect "<"
the contents of the 'pipe' file to gzip and gzip then creates it's own
file, exp_sid.dmp.gz.
The importance of solving this problem: To save time!
On unix, Solaris, Linux the exp and the gzip execute simultaneously!
I have not been able to do this using Dave Roths Win32 perl packages, the Win32::API
or IPC::Run. I have turned to C, C++ or even C# to try to accomplish this but have not been able to reproduce this.
I can create a named pipe with the OVERLAPPED struct. I can open the pipe using a simple client as provided by the MSDN but I cannot write to the pipe and also read from it simultaneously - the exp process executes first THEN the gzip processes the pipe contents. I tried to create a stream file instead and the same exact thing occurs.
My goal is to save time. Any direction toward solving would be a great help. I document all code with references from ALL sources and would identify contributors to this effort.
Thanks,
Tracy
|
|
|
|
|
Sorry no Google of any value to explain how CTabCtrl and spinner control work together.
FYI - the spinner controls magically appears when there are too many tabs to display and lets you move them around.
Thanks for reading
Vaclav
-- modified at 10:08 Monday 24th September, 2007
|
|
|
|
|
I always use this: Control Library[^]
The equivalent location in the platform sdk is User Interface/Windows Controls/Individual Control Information
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark for reminding me about “the other MSDN” !
Can I download it and retire my 2001 version?
Just kidding.
Unfortunately the tab control knows nothing about spinner control.
Maybe I am imagining things how they work together. Maybe they don’t.
I’ll keep digging around.
Cheers
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: Unfortunately the tab control knows nothing about spinner control.
What do you mean? They are two different controls (by spinner, you mean
up-down control, right?)
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
BTW, I've never seen any messages related to the up-down control that
a single-row tab control adds when there's too many tabs for the window width.
I don't know if there's any direct control available.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
I finally found how it is done. It was under my nose all this time.
The style options / parameter TCS_SINGLELINE brings in horizontal spinner control when the tabs do not fit into frame - pure magic! Of course the documentation does not say that verbatim.
I am still hacking the downloaded code to find how to replace
tab painfully created from scratch with tab created using CTabCtrl.
For now I consider this post solved - thanks to you Mark.
You get a star!
Here it is:
CTabCtrl::Create(WS_CHILD|WS_VISIBLE|(m_bTop?0:TCS_BOTTOM)| TCS_SINGLELINE
|TCS_FOCUSNEVER|TCS_FORCEICONLEFT|WS_CLIPSIBLINGS,
CRect(0, 0, 0, 0), pFrame, 42);
Cheers
Vaclav
|
|
|
|
|
Cool!
FYI...here's the only info I see in the SDK:
"If not all tabs can be shown at once, the tab control displays an up-down
control so that the user can scroll additional tabs into view. You can cause
a tab control to display multiple rows of tabs, if necessary, by specifying the
TCS_MULTILINE style. With this style, all tabs can be displayed at once."
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi there,
how can i check whether my application runs already or not on the system (OS),
so that if i try to start the application again,
instead of start a new instance of the application,
then just bring the application to the foreground.
thanks
|
|
|
|
|
|
Hamed Mosavi wrote: // "Life is very short and is very fragile also." Yanni
while (I'm_alive)
{
cout<<"I love programming.";
}
These many compilation errors in your small code. Are you a true lover of programming
error C2001: newline in constant
error C2015: too many characters in constant
error C2143: syntax error : missing ';' before 'constant'
error C2143: syntax error : missing ';' before 'while'
error C2001: newline in constant
error C2015: too many characters in constant
error C2143: syntax error : missing ')' before 'constant'
error C2143: syntax error : missing ';' before '{'
Sreedhar DV
[Real success is having courage to meet failure without being defeated.]
|
|
|
|
|
Sreedhar DV wrote: These many compilation errors in your small code
Oh my god! Did you really compile that!
I knew one day that happens. Someone notices the ' in I'm. I decided to put it there so that it would be more readable by non programmer members. It used to be 'Printf("...' and someone claimed it's better to use cout (because of it's performance! performance in CP!) Now if I remove that ' as well, I guess only programmers understand it;)
I decided to leave it to be, after all no one(?) is to compile or use this.
Sreedhar DV wrote: Are you a true lover of programming
Yes! Enough lover to continue coding for 6 years even when I don't earn enough money from that.;)
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
In all my years of doing software, this is the first time I've done a modeless dialog.
It works kinda -- the static text and progress bars are updating. But it's not getting it's other messages...
* WM_TIMER doesn't get there
* my button won't press
* the hourglass is up the whole time...
How do I get it to pump it's messages?
The dialog was created in a thread -- was wondering if that plays a role?
I did play with RunModalLoop -- but I am not sure that's what I really want to do????
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|