|
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>
|
|
|
|
|
If you provide the code you used to create and display the dialog, it's more likely to get answered.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Peter Weyzen wrote: The dialog was created in a thread -- was wondering if that plays a role?
Definitely. That thread needs to have a message loop and it sounds like your thread
doesn't.
You can either
a) change your thread to a UI thread
b) create the dialog on the app's UI thread.
In the case of a progress dialog, the second alternative is probably easiest. Let the
UI thread that's already in place handle the window messages and let the worker thread
do its intended work. Use PostMessage() from the worker thread to communicate
with the dialog.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: That thread needs to have a message loop and it sounds like your thread
doesn't.
Then what about his "...the static text and progress bars are updating" statement? Wouldn't those, too, fail to update without a message loop.
"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
|
|
|
|
|
Messages sent with SendMessage() will get to the control.
If the control handles the message with an immediate redraw
then it will "work".
For example. I'm pretty sure progress bar controls redraw themselves
immediately when you send a PBM_SETPOS message to them, although
that's nothing I'd rely on.
(*edit: Actually the PBM_SETPOS is documented as redrawing the control to reflect the change)
The timer and mouse messages queued by the sytem, however,
won't get to the control without being dispatched.
That's my take based on the info provided
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That's true -- I was able to update controls on the dialog.
The obvious clues were:
* WM_TIMER wasn't getting delivered
* dialogs controls wouldn't take input (couldn't click the buttons)
It would display data just fine, I just couldn't interact with the dialog.
Thanks again.
I guess I am not a dumb as I feel sometimes -- muddling through MFC.
I love CodeProject! It's truly the first place I go to look for answers or sample code. I think I've been a member for 6 years...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
After lunch and thinking about it, if your window displays, then the thread
it was created on must have a message loop. If you go into lengthy
processing on that thread without pumping messages, however, you'll
still get the behavior you described.
Cheers
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: After lunch and thinking about it, if your window displays, then the thread
it was created on must have a message loop.
I suggest you stop thinking so hard. Try this program:
#include "stdafx.h"
#include "resource.h"
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, &DialogProc);
ShowWindow(hDlg, SW_SHOWNORMAL);
Sleep(10000);
return 0;
}
There is no message pump but the window displays.
Steve
|
|
|
|