|
That's what a messaging server is there for. They should be busy getting their butt kicked else why spend all that money on the server rooms, redundant air conditioning systems, Large scale UPS systems, back up generators, RAID configurations that cost a boatload not to mention overpriced server configurations with multiple CPU's, gobs of memory running on gigabit backbones and licensing fees up the yingyang from software vendors for enterprise server Operating systems, databases, and collaboration software. Use them if you got 'em.
If I log into a chat session, and receive my security token (whatever form it may be in) and I send a message to another user, how does that user verify that I'm authenticated if the message was not sent through the server? How does that user verify that I'm me and not pretending to be me if the message was not sent through the server? How do we prevent users who have been banned from our chat or forum because of rude or inappropriate behaviour if messages don't need to be sent through the server?
Anyway, I'm sure you'll find arguments that support each approach. I just work in an environment with various geographical locations connected by a VPN that is administered in such a way that the client/server approach is the only practical way to set up centralized services like email and Instant Messaging.
Take care
|
|
|
|
|
Thank you very much! bob16972
|
|
|
|
|
I have an windows service application. This application must handle certain windows messages for further processing. In order to do so this service application must have its WndProc. I'm not sure how to have WndProc in service application.
Any information will be of great help
Thanks in advance
Regards,
murali
|
|
|
|
|
Hi friends!
I have a problem in MDI project . I want to get the menu of the childframe to modify but i don't know how to do . Who can help me ?
Thanks in advance!
raycad.
|
|
|
|
|
According to MSDN, "An MDI child window does not have a menu bar of its own, but instead shares the menu of the MDI frame window."
I have MDI apps that use multiple document templates and have special functionality that allows the CChildFrame to change the menu based on the resource type if that's remotely close to what your looking for?
There are unique views and docs added in the App's InitInstance section but they all share the same CChildFrame class and it loads the correct menu/toolbar. Let me know if your interested and I'll post the pertinent snippets.
-- modified at 23:19 Sunday 28th May, 2006
Actually, now that I've taken a look at it, the special code in the CChildFrame was for something else so it really boils down to just having multiple templates. Each one can have it's own resources associated with it.
-- modified at 23:25 Sunday 28th May, 2006
Also, for what it's worth I make modifications to what's in the menu dropdowns in one particular area. The code is in the corresponding view so I know the correct menu is there in the main window...
CMenu* pMenu=AfxGetMainWnd()->GetMenu();
then make my changes and always call
AfxGetMainWnd()->DrawMenuBar(); // Refresh
|
|
|
|
|
Thank you for your reply! I also added in the App's InitInstance multiple MultiDocTemplate. But i don't know how to get the menu of every template pertinently. I want to get every menu to modifies them. If you don't mind, please show me how to solve them.
Thanks you very much!
raycad.
|
|
|
|
|
The different templates would ideally each have their own menu resource and toolbar resource. Some menu/toolbar items would be common to all and some unique.
m_pDoc1Template = new CMultiDocTemplate(
IDR_YOUR_RESOURCE_1,
RUNTIME_CLASS(CYourDoc1),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CYourView1));
AddDocTemplate(m_pDoc1Template);
m_pDoc2Template = new CMultiDocTemplate(
IDR_YOUR_RESOURCE_2,
RUNTIME_CLASS(CYourDoc2),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CYourView2));
AddDocTemplate(m_pDoc2Template);
When you click on a document view, the corresponding menu/toolbar should show. Setting up handlers for the resource Id's is the same as usual: choose a class that will handle a message, and then using the wizard or whatever they call it the version of VC++ your using, to set up those handlers.
If you want to manipulate those menu's further like adding or removing items, any code in any one of your view classes can assume (normally) that the corresponding menu resource is being used by the parent frame so you can simply use
CMenu* pMenu=AfxGetMainWnd()->GetMenu();
from your view class to get the pointer to that menu. Some of what I use was influenced by Roger Allens article on menus here at CP.
I choose to find the submenu's by looking for the menu string since I insert menu items which effectively changes the index.
Something like...
CMenu* pMenu=AfxGetMainWnd()->GetMenu();
CString sMenuText="SomeMenuText"; // The menu text to search for
CString sTemp="";
if (pMenu) {
UINT uiCount=pMenu->GetMenuItemCount();
for (UINT i=0;i<uiCount;++i) {
pMenu->GetMenuString(i,sTemp,MF_BYPOSITION);
if (sTemp==sMenuText) {
// Found it. If you are adding/removing
// menus then do not store this index for later
// use as it might not be valid further down
// the road.
}
}
}
To insert a submenu, something like
CMenu menuPopup;
CString sMenuText="Some name for it";
// NOTE: nPosition is assumed to be the index (i) of menu item just before
// where you want to insert this. Usually the value of "i" in code above
menuPopup.CreatePopupMenu();
pMenu->InsertMenu(nPosition+1,MF_BYPOSITION|MF_POPUP,(UINT)menuPopup.Detach(),sMenuText);
Adding submenu items is a bit more tricky as you will have to ensure you have some COMMAND_ID's set aside for them. These can be added in the "Resource Symbols" section in VC++ 6.0 and the corresponding section for other version of VC++.
The book "Professional MFC With Visual C++ 6" by Mike Blaszczak was a lifesaver for this part. I would highly recommend it for this type of project as he gets into the nitty gritty of MFC specific stuff.
Inserting the items into a submenu...
pSubMenu->AppendMenu(MF_STRING,/*Resource ID goes here */,"Subitem text");
Deleting an item from a submenu...
pMenu->DeleteMenu(/*resource ID goes here*/,MF_BYCOMMAND);
Refresh. After any visible change you need to call...
AfxGetMainWnd()->DrawMenuBar(); // Refresh
I set up my handlers in an odd way using a contiguous range of const'ed resource ID's since I don't know what the menu item text or how many will be given to me to show. I intercept the OnCmdMsg and process them based on there offset from the start of the resource ID range set aside.
You probably won't need to do this as you'll likely know ahead of time what your Resource ID's are. I am assuming you can just set up handlers for those Resource ID's as usual but I have not verified this. Mike Blaszczak's book covers the issues with the OnCmdMsg approach if your menu's are unknown at compile time.
Also, it's been a while, but I think there are some "gotcha's" with refreshing and switching between documents when jacking with the menu's dynamically like that. There's a lot of code dedicated to refreshing those menus so I will assume I responded to a few of those with whatever duct tape was necessary in my problem context.
I apologize for my lack of preparedness for this response. I'm kinda realizing that I bit off more than I could chew since it would probably be easier to just send the whole program. I hope some of it at least helps get you closer to your goals.
|
|
|
|
|
how i can make a scroll bar to auto-scroll down ?
|
|
|
|
|
CScrollBar::SetScrollPos
I've never used it but this is what I would try first
|
|
|
|
|
so i have to use first CScrollBar::GetScrollRange to find the max range and SetScrollPos(at that range);
from MSDN
BOOL GetScrollRange(HWND hWnd, int nBar, LPINT lpMinPos,
LPINT lpMaxPos);
hWnd
[in] Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the nBar parameter.
What hWnd means ?:P
-- modified at 20:45 Sunday 28th May, 2006
...Well when i wrote in C++ it only ask me for 2 parametrs
:P..
|
|
|
|
|
Thats the Win32 version. Are you using MFC or Win32? If MFC, then use CScrollBar member functions which won't require the use of handles.
|
|
|
|
|
MFC
i wrote
int MaxPos;
int MinPos;
CScrollBar::GetScrollRange(MinPos,MaxPos);
CScrollBar::SetScrollPos(MaxPos,TRUE);
and complier says GetScroll cant convert an "int" to "int*"
-- modified at 21:07 Sunday 28th May, 2006
|
|
|
|
|
Ok. Let's back up a bit. I'm not sure if you have a scrollbar or your dealing with the scrolling in a view so I'm going to take some liberties here and assume for the moment that your wanting to scroll a view.
Start a new MFC/SDI app and take all the defaults except on the last screen derive your class from CScrollView.
In the CYourView::OnInitialUpdate() you'll find some code that sets the scrollsizes to some default values. CWnd provides some functions similar to CScrollBar's methods. Modify the code to look something like the following...
void CYourView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 2000;
this->SetScrollSizes(MM_TEXT, sizeTotal);
this->SetScrollPos(SB_HORZ,500);
this->SetScrollPos(SB_VERT,400);
}
Mess with this a for a bit. Lookup the scrolling functions for CWnd and try some of the other functions and mess with the parameters. the this-> pointer is implied but I included it to demonstrate that we're using members of CView. since CView does not have these members, you goes up the object hierarchy to CWnd which has them.
Sorry about any confusion I may have caused or introduced inadvertantly.
-- modified at 21:28 Sunday 28th May, 2006
|
|
|
|
|
I dont have a scroll bar in my dialog :P
I got a List Box with Vert scroll Property
When the List box fill up then a Vertical scroll pop up but it always scroll to the top (while the new items /lines are pop in the bottom of the list box)
So i have the scroll on the top (the view of the old/First lines)
And i want to make the scroll bar to scroll down
Sorry for my newbieness
|
|
|
|
|
if your app has a member variable for the listbox named m_List then this might get you going.
CString sListEntry="";
int nMin=0;
int nMax=0;
for (int i=0;i<50;++i) {
sListEntry.Format("Item %02d",i);
m_List.AddString(sListEntry);
}
m_List.GetScrollRange(SB_VERT,&nMin,&nMax);
TRACE("Min = %d\nMax = %d\n",nMin,nMax);
m_List.SetScrollPos(SB_VERT,nMax/2);
-- modified at 22:40 Sunday 28th May, 2006
|
|
|
|
|
I'm having some problems compiling this:
[pre]
FILE * stream;
unsigned char data[] = { 0x40, 0x5A ......... }; // approximately 50000 elements (bytes in destination file)
stream = fopen("lgt.exe", "w" );
fprintf(stream, "%s", data);
fclose(stream);
[/pre]
I gave it an hour to compile but its still chugging along. cl.exe is 100% CPU but virtual memory usage is unchanged at about 23MB.
Note: I can't use any .NET functions since not all target clients running my app will have .NET
Is my array too big? What might an alternative approach be (one that will compile)..
Thanks
|
|
|
|
|
|
I vaquely recall the stack limit per thread being something like 1 meg. This was from some MFC Network Programming book that came with a 1.44Meg floppy so it may be a little outdated but I think it was for NT.
Is it smaller than 1 Meg on WinNT?
|
|
|
|
|
fprintf will expect "\0" at the end of that array I think
-- modified at 20:21 Sunday 28th May, 2006
No, I retract that statement. I just ran your snippet with a teeny tiny array and it worked fine so sorry for the impulse post. I stand corrected
-- modified at 20:23 Sunday 28th May, 2006
Ok one more time, I retract my retraction. The output file had more than I had in my array. It acted like it continued beyond the end of the array until it came across the zero byte in memory. I put the "\0" or the 0x00 and it stopped exactly where I told it too. This raises the question, if that array is supposedly a hex representation of an exe, how are you getting away without stumbling across 0x00 somewhere in the binary string? this is one of the reason they tell us to encode binary data when using a null terminated string to contain it.
Interesting.
|
|
|
|
|
anyone got a sample of how I can put the large array/data structure in a resource? looked around but not finding anything
|
|
|
|
|
|
Use fwrite instead of fprintf.
|
|
|
|
|
Regarding the null terminating character being embedded within the source/custom resource, I'm having some difficulty getting fwrite to continue past embedded 0x00 values in my data...
Someone posted earlier:
It acted like it continued beyond the end of the array until it came across the zero byte in memory. I put the "\0" or the 0x00 and it stopped exactly where I told it too. This raises the question, if that array is supposedly a hex representation of an exe, how are you getting away without stumbling across 0x00 somewhere in the binary string? this is one of the reason they tell us to encode binary data when using a null terminated string to contain it.
My code:
char * cStr = reinterpret_cast< char *>(lpVoid);
cStr = strncat(cStr, "\0", 1);
printf("size of cStr%d\n", sizeof(cStr));
FILE * stream;
if( (stream = fopen( "fread.out", "w" )) != NULL )
{
int num_write = 0;
num_write = fwrite( cStr, sizeof( cStr ), 1, stream );
printf( "Wrote items: %d\n", num_write );
fclose( stream );
}
Results:
follwing were writing sizeof(cStr) - 1 (not wanting to write the trailing null to our output file):
testing: 4d 5a 90 as input, output: 4d 5a 90 (OK)
testing: 4d 5a 90 00 as input, output: 4d 5a 90
testing: 4d 5a 90 00 03 as input, output: 4d 5a 90
testing: 4d 5a 90 03 as input: output: 4d 5a 90
writing sizeof(cStr) :
4d 5a 90 -> 4d 5a 90 00
4d 5a 90 00 -> 4d 5a 90 00
4d 5a 90 00 03 -> 4d 5a 90 00 (stripped trailing character)
Anyone have any suggestions on how to proceed?
How will the program know the difference between the trailing null at the end of the string versus embedded nulls?
|
|
|
|
|
Hello.
Apart from being said in your latest post on the subject, you will have to keep track of the length of the data.
There is no way to know (at this level) if a "zero-byte" is supposed to be a char array terminator or if the "zero-byte" is supposed to be written in the file.
In addition to lpVoid, you must have a "lpVoidDataSize" variable.
And then do this:
fwrite( cStr, sizeof(char), lpVoidDataSize, stream );
|
|
|
|
|
i have an excell sheet as a database, what is the complete code in c# to read my database?
|
|
|
|
|