|
Notice anything peculiar about your code snippet? Yeah, we can't decipher it either.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi, i am sorry i wrote just words to explain the way i have coded it. basically what i have is a class (CIPCClass) which encapsulates namedpipe functions and in the mainthread i create an instance of that class CIPCClass and when a client has connected i call the startthread of the CIPCClass to continue the receiving of message while the main thread can again continue to listen for connecting clients.
mainthread
{
CIPCClass obj;
for(; ; )
{
obj.CreatePipe();
int nRet = obj.ConnectNamedPipe();
if(nRet)
obj.StartThread();
else
break;
}
}
the above approach did not work so i created a minorthread which receives the CIPCClass. and from the minorthread then i will call the startthread. still it did not work.
hope i have explained it clear enough. sorry again.
thanks for any help.
newbie
|
|
|
|
|
Using the <pre&gr tags keep the indentation and any < or > symbols.
It will also make it easier on people's eyes to read - so someone might actually answer.
Iain.
|
|
|
|
|
ginjikun wrote: hope i have explained it clear enough.
What does "did not work" actually mean?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
If code isn't indented I don't bother to look at it.
Steve
|
|
|
|
|
my listbox is showing what is going on with my program as it happens...
i need it to add the text in order from when it was called instead of alphabeticly or however it's doing it right now how can i fix this? thanks
|
|
|
|
|
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
|
|
|
|