|
Are you sure is crashing or just asserting? Most likely it is the latter and it looks something like this:
ASSERT(IsWindow(hwnd));
With limited info you gave in your post, I can only guess that tab object was not created (windows is not attached to the MFC object). You have to either call Create or subclass the tab control.
I would strongly suggest two things:
Reconsider 200 tabs; it seems a little too many to handle by the user (not to mention control).
Consider using property sheet (CPropertySheet) and property pages (CPropertyPage). Property pages behave like dialogs.
JohnCz
|
|
|
|
|
The msdn says #pragma pack(n) will change current alignment value to n.
But if n is zero, what will do?
|
|
|
|
|
it resets the packing to the default size
(actually, what it does depends on the compiler. some compilers don't support pack(0) at all, and some use it as a reset)
modified 22-Apr-12 14:33pm.
|
|
|
|
|
Nope. Default size is NOT stating a #pragma pack, which defaults to DWORD, ie 4 byte alignment in structures.
#pragma pack 0 means there is no packing between data members, so they are contiguous in memory.
--edit--
Actually I am talking crap. pack (1) makes data member contiguous in memory, pack (0) resets packing. DOh!
==============================
Nothing to say.
modified 23-Apr-12 4:37am.
|
|
|
|
|
Erudite_Eric wrote: pragma pack 0 means there is no packing between data members, so they are contiguous in memory.
no. that's pack(1) : align on single bytes.
pack(n) specifies the structure alignment, not the number of bytes between structs.
|
|
|
|
|
Doh! Quite correct.
==============================
Nothing to say.
|
|
|
|
|
Here n has to be 1,2 4, 8 ....
Now if don't specify any value or if the value is 0, then the members are packed to default packing size (which is 8 for many compilers).
However few compilers will throw compilation error.
|
|
|
|
|
Nope. Default size is NOT stating a #pragma pack, which defaults to DWORD, ie 4 byte alignment in structures.
#pragma pack 0 means there is no packing between data members, so they are contiguous in memory.
--edit--
Actually I am talking crap. pack (1) makes data member contiguous in memory, pack (0) resets packing. DOh!
(Just checked my code. Its been a few months since I did any, I guess the old memory is fading....)
==============================
Nothing to say.
modified 23-Apr-12 4:38am.
|
|
|
|
|
#pragma pack(0)
#include <iostream>
using namespace std;
struct Test
{
char a;
int i;
};
void main()
{
cout<<sizeof(Test)<<endl;
}
I am using VS2008 SP1. The build is x86.
Now guess the result of sizeof(Test) ??
|
|
|
|
|
5
==============================
Nothing to say.
|
|
|
|
|
I am reading 8 on my console.
|
|
|
|
|
Yeah, it is 8, DWORD alignment. I got it wrong...
==============================
Nothing to say.
|
|
|
|
|
|
#pragme pack 0 takes out all pading between data members in a struct so they are contiguous in memory. Very useful indeed since pretty much every data stream has no padding since it wastes bandwidth so being able to cast a chunk of memory to some zero packed struct gives you immediate and easy access to those data members.
Consider an ethernet framed IP packet containing UDP and DHCP data. You can build a struct to grab the IP address requested directly from the data.
--edit--
Actually I am talking crap. pack (1) makes data member contiguous in memory, pack (0) resets packing. DOh!
==============================
Nothing to say.
modified 23-Apr-12 4:39am.
|
|
|
|
|
Why don't you continue reading MSDN ?
#pragma pack documentation[^] states:
Valid values are 1, 2, 4, 8, and 16.
Hence 0 is 'not valid' (I wouldn't try to make assumptions on a value marked as such).
Veni, vidi, vici.
|
|
|
|
|
Just after read MSDN, I found that the case n=0 is ignored. I do not know why.
|
|
|
|
|
Simply because it's not explicitly handled.
Without giving the directive a special meaning for n=0, it makes perfect sense - it keeps the use of the directive consistent.
|
|
|
|
|
yu-jian wrote: But if n is zero, what will do?
Add /WX to your compiler settings and recompile. You should pay more attention to compiler warnings.
Best Wishes,
-David Delaune
|
|
|
|
|
There is a error that Visual Studio 2008 only supports 1, 2, 4, 8... After add /WX to compiter.
|
|
|
|
|
See the documentation[^], which clearly states that the only valid values for n are 1, 2, 4, 8 and 16. Thus using 0 is an invalid #pragma and will be ignored: the default packing (8) will be used.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
Thank you for everyone's replies.
|
|
|
|
|
According to the C++ standard it can do whatever it likes. It's a way of implementors switching on non-standard features of the compiler. I think Griff and the others have told you enough about what it does on VC++ though!
Cheers,
Ash
PS: Except this is the one thread Griff hasn't posted in. Let's try "Chris and the others..." instead!
|
|
|
|
|
I want to click a button, load the dialog with progress bar, run a validator in a new thread, and then close the dialog.
So I used the toolbars WndProc to load DialogBox( sdfsdfsdf
Then in the Dialog Proc, WM_INITDIALOG, created the dialog controls, the dialog box is at top level, and fully painted, the dialog proc exits.
Is there a message sent after the dialog box intializes and loads, that I can capture so I can send the next message to run the validator?
I tried adding the SendMessage to the end of the WM_INITDIALOG, but the box won't show until the validator exits. Bad Idea.
switch (message) {
case WM_INITDIALOG:
{
_project_SQLExplorer_Dialog_hWnd = hWndDlg;
_project_SQLExplorer_Dialog_Validate_CreateControls( hWndDlg );
return (INT_PTR)FALSE;
}
case WM_ENTERIDLE:
SendMessage( hWndProject_SQLExplorer, WM_COMMAND, (WPARAM) IDM_SQL_EXPLORER_VALIDATE_START, (LPARAM) 0 );
break;
case WM_COMMAND:
switch LOWORD(wParam) {
case IDCANCEL:
EndDialog(hWndDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
case WM_PAINT:
_project_SQLExplorer_Dialog_Validate_Paint( hWndDlg );
break;
case WM_CLOSE:
EndDialog( hWndDlg, 0 );
break;
}
|
|
|
|
|
Well so far, I have learned that I have to let the Dialog Proc exit in order for the Dialog box to show.
So I edited my Create Thread Function to just create the thread and let it fly through, without waiting for any exit codes or messages, and then the thread takes over to update the Dialog Box, and closes the dialog box with another message.
It works, and looks clean, if there's a better way let me know.
|
|
|
|
|
Hi,
I have one text file which stores the hex values in different lines(APDU.txt).
Eg; 02 01 00 BE 10 04 0E 08 00 06
10 00 2B 61 29 A1 09 06 07
And I need to process this line by line.
Here is a sample code that m used so far;
FILE *myFile = fopen("D:\\APDU.txt", "rb");
BYTE *buffer,*buffer1;
int lengthFile=0;
char temp[3];
if(myFile!=NULL)
{
fseek(myFile,0,SEEK_END);
lengthFile=ftell(myFile);
fseek(myFile,0,SEEK_SET);
buffer=new BYTE[lengthFile+1];
memset(buffer,0,lengthFile+1);
fread(buffer,sizeof(BYTE),lengthFile,myFile);
fclose(myFile);
}
buffer1=new BYTE[lengthFile/2];
memset(buffer1,0,lengthFile/2);
memset(temp,0,sizeof(temp));
for(int i=0,j=0;i
|
|
|
|