|
I use the MSDN recommended XML Documentation[^] these days, but I only code for my own amusement.
The best things in life are not things.
|
|
|
|
|
I also use Doxygen, but I've also set up my UML tool, Enterprise Architect, to automatically convert the comments I add in the diagrams to the right format for Doxygen, and I set up my VisualAssist makros to also create function header documentation in the right format with all parameters and the return value listed. So all I have to do is fill in the actual meaning, no matter whether the code comes straight from UML, or has been added within VS.
The funny thing is, noone ever looks at the docs I created with Doxygen, people (including myself) are happy enough just with the oddly formatted comments 
|
|
|
|
|
What are the differences between overlapped window and popup window. Does the overlap mean that window can overlap each other? and popup window can't?
|
|
|
|
|
Perhaps you should return to go and collect $200?
MSDN: Window Styles[^]
|
|
|
|
|
enhzflep wrote: Perhaps you should return to go and collect $200?
where i should i give my account no!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I think the Microsoft documentation could be a bit clearer. In reality the basics of both types are the same but the overlapped window has a title bar and a border. you can see for yourself by creating a very basic Win32 program (as described in Win32 Window Minimal[^]) and experimenting with the different window styles.
The best things in life are not things.
|
|
|
|
|
Hello,
I need to use this macro to make my menus, but this don't work right!
All samples that I have are used with CMainFrame class.
I need this to use wit CDialog based application!
My question is, works this macro with(in) CDialog???
Thanks for any help!
Arrin
|
|
|
|
|
Have you tried it, and if so, what were your results? Alternatively you can find a lot of suggestions here[^].
The best things in life are not things.
|
|
|
|
|
You'll need to handle the WM_KICKIDLE message in order to work with ON_UPDATE_COMMAND_UI in your dialogs.
Here[^] is a very detailed article on this topic.
This[^] CP article might also be useful. 
|
|
|
|
|
Hello !
I use WSAAsyncSelect to do a small ChatSystem in the WLAN Server.
(the max client may be has 100-200 online,and the ordinary time is 30-50 online at the same time.)
like this:
SOCKET sock = (SOCKET) wParam;
if(WSAGETSELECTERROR(lParam)){
DeleteClient(sock);
return;
}
switch(WSAGETSELECTEVENT(lParam)){
case FD_ACCEPT:
sClient = accept(wParam, (struct sockaddr *)&client, &iAddrSize);
WSAAsyncSelect(sClient, hwnd, WM_SOCKET, FD_READ | FD_CLOSE);
break;
case FD_READ:
ReadData(sock);
break;
case FD_CLOSE:
DeleteClient(sock);
break;
default:
break;
}
at last ,when add/del client, it will refresh onlines info to the Server's list control. May be it doesn't receive the FD_CLOSE message.
but usually ,it has some few days ago results. I run in the Lan and use other Lan computer to test it, but can't found this problem.
How about this ?
Thanks for you reply !
|
|
|
|
|
hello i hope this will work.
don't use WSAAsyncSelect() probably your window might be missing some messages posted by
mfc socket framework (This will happen)
use WSAEventSelect() by creating one more thread. send notification messages to your main window by using SendMessage() function. it will work perfectly.
Possibly one more reason is
Socket abort operation notification will take at most 2 msi cylcles ( 1 msi is 2 minutes).
this is tcp ip implementation
bye
yln
|
|
|
|
|
If client side closes normally, Close-event will be sent to server.
But, if internet or network connect-line breaks or some odd things happen, Close-event will not be sent to server.
in your test, you closed client socket normally, so you can't find problem.
try to plug out connect cable to see what happens.
|
|
|
|
|
may be is right , but is there any way to fix it ?
|
|
|
|
|
Hello,
I have a program with a list of structs which I am iterating over. I would like to pass the individual structs to another function as I iterate over them but I can't seem to figure out how to do it. I'm new to working with lists and iterators so there is probably an easy way to do this but I couldn't find any reference to it in Google searches or a search of this forum.
Here is an example of what I would like to do:
struct MyStruct{
int int1;
bool bool1;
};
void MyFunction(MyStruct myStruct)
{
cout << myStruct.bool1 << endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
list<MyStruct> structList;
list<MyStruct>::iterator structIterator;
MyStruct myStruct;
MyStruct myStruct2;
myStruct.int1 = 2;
myStruct.bool1 = true;
myStruct2.bool1 = false;
myStruct2.int1 = 5;
structList.push_back(myStruct);
structList.push_back(myStruct2);
structIterator = structList.begin();
while (structIterator != structList.end())
{
MyFunction(structIterator);
structIterator++;
}
return 0;
}
Apparently structIterator points to the actual struct but I don't see how to get to it from here. Any help is greatly appreciated.
Thanks,
Craig
modified on Thursday, July 14, 2011 11:25 AM
|
|
|
|
|
Try this - MyFunction(*structIterator);
|
|
|
|
|
Of course that makes perfect sense and it worked like a charm. I knew it would be something simple and if I had better pointer knowledge I probably would have figured it out on my own.
Thanks so much for the solution.
|
|
|
|
|
Folks,
Quick question in relation to the Pointer Maths in this program below, The Output is as follows:
1, 2, 3
. . .
. . .
. . .
245026, 245027, 245028
246017, 246018, 246019
247010, 247011, 247012
248005, 248006, 248007
249002, 249003, 249004
The Last Record is : 245028
Using the MoveBack function I expected the output to be 248007, the record before the current record, however it seems we move back 12 blocks of memory to 245028 and not the 12bytes I expected. Can someone explain to me whats going on here and how I can modify the code to get 248007 from the function? Thanks In Advance
#include "stdafx.h"
#include <conio.h>
typedef struct MyStruct{
int i;
int j;
int k;
} TheStruct;
int MoveBack(int *iPos);
int main(int argc, char* argv[])
{
TheStruct ts[500];
int i = 0;
for(i = 0; i < 500; i++)
{
ts[i].i = i * i + 1;
ts[i].j = i * i + 2;
ts[i].k = i * i + 3;
}
for(i = 0; i < 500; i++)
{
printf("%ld, %ld, %ld \r\n" ,ts[i].i ,ts[i].j, ts[i].k);
if(i == 499)
{
printf("The Last Record is : %ld" , MoveBack(&ts[i].k));
}
}
while(!getch());
return 0;
}
int MoveBack(int *iPos)
{
int *i = iPos - sizeof(TheStruct);
return *i;
}
|
|
|
|
|
Adding or subtracting from a pointer will always be done in multiples of the size of the type pointed to. In this case, MoveBack subtracts 12 times the size of an int from the address, since i points to an int (or at least that's how you declared it). If you don't want that, you have to use void* rather than int* .
That said, it's a horrible idea to cast a pointer into an array of some struct to int* ! Why don't you just pass a pointer to MyStruct instead? Also, it's an even worse idea to dereference an int pointer that in truth points to a struct. This may or may not work, depending on the compiler. And if you ever choose to modify your struct later, the code will likely break (provided it did actually work before).
MyStruct* MoveBack(const MyStruct* p)
{
return p-1;
}
printf("The Last Record is : %ld" , MoveBack(&ts[i])->k);
P.S.: Note that this solution
a) makes the function independent of the definition of MyStruct
b) gets rid of error prone type casts
c) removes the need to use sizeof
d) is actually shorter, to the point that you could inline it, or simply forgo the function alltogether (e. g., above you could write (&ts[i]-1)->k )
P.P.S.: you could of course just use ts[i-1].k
That would be technically equivalent to the code I suggested under d) above
modified on Tuesday, July 12, 2011 9:59 AM
|
|
|
|
|
What if p points to element 0 of the array? How would you check for this?
|
|
|
|
|
You can't. Not inside MoveBack() anyway. Which is yet another good argument not to meddle with pointers recklessly.
The only way to ensure a pointer is inside the scope of an array is to compare it to the start address, and only the function that defined the array knows it.
So if you really wanted a 'safe' MoveBack function, you'd have to add a parameter, like this:
MyStruct* MoveBack_s(const MyStruct* p, const MyStruct* parray)
{
MyStruct* result = 0;
if (p > parray)
result = p-1;
return result;
}
Of course, even this function is not safe if you pass it a pointer to the start of a different array...
The only way to be truly safe is not to use pointers, but iterators, such as those used for the STL class vector. They contain references to the container they refer to and therefore can check their boundaries themselves.
|
|
|
|
|
When using sizeof with a structure it is not guaranteed that you get the sum of the single components due to Structure padding (wiki for it). Just printf the sizeof() of your struct and you will see that its not 12 Bytes.
Anyway it is very unclear to me why are you even trying to do it this way. Dont mess with addresses and pointers in such an unsafe way. Who even tells you that you could just decrease the given int pointer and it would still point to a valid adress.
E.g. just use the indices of the array to get the last element.
|
|
|
|
|
I made a code snippet to print the size of his structure and it was in fact 12 bytes.
|
|
|
|
|
Well i was a bit fast with saying that it will not be 12 bytes. Of course it depends on the compiler. I just wanted to state that its not allways 12 bytes.
|
|
|
|
|
Why on earth was this rated as a bad answer?
Each of the points made are valid and important. Let's see if a 5 won't help!
|
|
|
|
|
Legor wrote: When using sizeof with a structure it is not guaranteed that you get the sum of the single components due to Structure padding
But it doesn't matter since you will always get the size of the actual structure as created by the compiler, so you can still use sizeof to increment a void pointer.
However, as you rightly point out, that is a stupid way to do it since normal increment/decrement or indexing is the correct way.
The best things in life are not things.
|
|
|
|