|
Taken from MSDN......
Array
An array is a collection of like objects. The simplest case of an array is a vector. C++ provides a convenient syntax for declaration of fixed-size arrays:
Syntax
decl-specifiers dname [ constant-expressionopt ] ;
The number of elements in the array is given by the constant-expression. The first element in the array is the 0th element, and the last element is the (n-1th) element, where n is the size of the array. The constant-expression must be of an integral type and must be greater than 0. A zero-sized array is legal only when the array is the last field in a struct or union and when the Microsoft extensions (/Ze) are enabled.
Arrays are derived types and can therefore be constructed from any other derived or fundamental type except functions, references, and void.
Arrays constructed from other arrays are multidimensional arrays. These multidimensional arrays are specified by placing multiple [ constant-expression ] specifications in sequence. For example, consider this declaration:
int i2[5][7];
It specifies an array of type int, conceptually arranged in a two-dimensional matrix of five rows and seven columns
5 ROWS X 7 COLUMNS!
|
|
|
|
|
That's not my problem though. I know what a matrix is and how to declare one; it's that my
CButtonST *buttonArray[10][20]
matrix is making a matrix of 20 rows X 10 columns, which is in the wrong order.
|
|
|
|
|
Since you haven't given much detail, here is just a wild stab. I am assuming you are thinking in your code not of "row" and "column" but perhaps as "x" and "y". What you have written ("buttonArray[10][20]") we know to be 10 rows of 20 columns, but if you think of it as "x" and "y" you may get your loop indexes reversed.
Since "x" and "y" relate to a Cartesian coordinate system, the "x" axis is typically the horizontal axis, but it actually measures columns (which increase horizontally). Likewise, "y" is the vertical axis and it measures rows.
Therefore, and again this is just a wild stab, if you are programming using "x" and "y" as your loop index variables, you are going to want to reference elements in the array as "buttonArray[y][x]" just as you would if you were using "row" and "col" (buttonArray[row][col]).
What is it that is telling you that the array is actually [20][10] instead of [10][20]?
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
Help me please, i need some data packing algoritms for text/binary data's.
thank you !
|
|
|
|
|
Try out "ZLIB" it is GNU but it is worth it...
|
|
|
|
|
If you look for example at the folder icon in windows on XP you see it has a small 1-2 pix shadow on it. But when I draw the image this "shadow" get completly black.
And make everything look strange. You get the icon with a black line around the image.
I tried everything. (well, perhaps not ) I created the ImageList with different color depths ILC_COLOR32 / ILC_COLOR24 / ILC_COLOR16 and draw the image with different parameters, But nothing help
Anyone know how to draw them ??
|
|
|
|
|
After many hours of searching the Net and news group I found the answers.
The System Icons on XP have a Alpha channal and it is this that is drawn black.
To make it draw correctly on XP I had to include a "manifest" into my project.
So comctl32.dll version 6.0 is started insted of 5.x
|
|
|
|
|
I am computing average of some readings. For each reading I am taking n samples .
My steps are 0 , 0.5, 1.0 .... till 4.5 after which the increments are smaller like 4.5, 4.6,4.7,4.8...
I am doing the following comparision
float vin ;<br />
float x;<br />
loop <br />
if((vin==x) ){<br />
Compute sum for this vin value ; i.e sum =sum + newValue <br />
samples++<br />
}<br />
else{<br />
if(vin!=x ){<br />
sampleArray[sampleCount].thisAverage=sum/(samples);<br />
sampleCount++;<br />
if(x>4.5)<br />
vin+= 0.10000; <br />
else<br />
vin+=0.5;<br />
<br />
samples=1;<br />
}<br />
}
What I am observing is this
everything works Okay until vin reaches 4.80000
There is a comparision done as shown in code above
if((vin==x) ){<br />
Compute sum for this vin value ; i.e sum =sum + newValue <br />
samples++<br />
}
using debug I am able to see that both vin and x are 4.80000 but
the expression (vin==x)evaluates to 0 and the "else" code kicks in !!!
definately there is something weird going in here which I am unable to grab ! I need some help understanding this !!! Please help
|
|
|
|
|
When doing comparision between float(or double), you'd better take into account precision.
for example something like :
double fSomeTolerance = 0.0001;
if ( fabs(vin - x) < fSomeTolerance )
{
ASSERT( 0 );
}
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
i do get ur point, but then why do my previous comparisions for
0.5,1.0,1.5......4.5,4.6,4.7 work ok ?
|
|
|
|
|
4.8 was probably just the point where the tolerance of the comparison started to make a difference. Rounding errors are a similar problem that can not make itself shown for awhile, but the cumulative effect of a lot of operations finally cause an error down the road.
|
|
|
|
|
Very good!
Why? Because comparing floats and doubles for equality is notoriously unreliable, it is some thing you just don't do.
|
|
|
|
|
Hi!!!
I am currently writing OnContextMenu handler. This is supposed to show Shortcut menus when the user presses Right click.
The menu is coming up right but none of the text shows up. Can someone point me to some example which has implemented this or let me know if you have written this part of UI code?
Thanks in advance.
P.S. Windows API Gui is way too whacked. But once it all comes together it is cool
|
|
|
|
|
Post an example of the code that creates and displays the context menu.
Kuphryn
|
|
|
|
|
HMENU hPopMenu = NULL;
MMMENUITEMINFO lpCoolMenuItemInfo, lpCoolMenuItemInfo1;
if (!hPopMenu) hPopMenu = ::CreatePopupMenu();
//lpCoolMenuItemInfo.hSubMenu = NULL;
//lpCoolMenuItemInfo.HotImageListIndex = ::LoadIcon(NULL, MAKEINTRESOURCE(IDI_TEST));
//lpCoolMenuItemInfo.NormalImageIndex = ::LoadIcon(NULL, IDI_TEST);
strcpy(lpCoolMenuItemInfo.szText, "Test 1"); //"Context Menu";
lpCoolMenuItemInfo.uPos = 0;
lpCoolMenuItemInfo.wID = 1;
MENUITEMINFO MenuItemInfo;
MenuItemInfo.fMask = MIIM_TYPE | MIIM_STATE;
MenuItemInfo.fState = MFS_DEFAULT ;
if (lpCoolMenuItemInfo.fType == MFT_SEPARATOR)
{
MenuItemInfo.fType = lpCoolMenuItemInfo.fType;
return InsertMenuItem(hPopMenu,lpCoolMenuItemInfo.uPos,1,&MenuItemInfo);
}
else
{
MenuItemInfo.fMask |= MIIM_DATA | MIIM_ID;
MenuItemInfo.fType = MFT_OWNERDRAW;
MenuItemInfo.wID = lpCoolMenuItemInfo.wID;
MenuItemInfo.cbSize = sizeof(MenuItemInfo);
MMMENUITEMINFOPTR lpcmii = (MMMENUITEMINFOPTR) ::malloc(sizeof(lpCoolMenuItemInfo));
MenuItemInfo.dwItemData = (unsigned long) lpcmii;
::strcpy (lpcmii->szText, "Microsite" ); //lpCoolMenuItemInfo.szText) ;
//lpcmii->HotImageListIndex = lpCoolMenuItemInfo.HotImageListIndex;
//lpcmii->NormalImageIndex = lpCoolMenuItemInfo.NormalImageIndex;
lpcmii->uPos = lpCoolMenuItemInfo.uPos;
lpcmii->fType = MenuItemInfo.fType;
//lpcmii->cAccel = *(p+1);
::InsertMenuItem(hPopMenu,lpCoolMenuItemInfo.uPos,1,&MenuItemInfo);
}
strcpy(lpCoolMenuItemInfo1.szText, "Test Part 2"); //"Context Menu";
lpCoolMenuItemInfo1.uPos = 1;
lpCoolMenuItemInfo1.wID = 2;
MENUITEMINFO MenuItemInfo1;
MenuItemInfo1.fMask = MIIM_TYPE | MIIM_STATE;
MenuItemInfo1.fState = MFS_DEFAULT;
if (lpCoolMenuItemInfo1.fType == MFT_SEPARATOR)
{
MenuItemInfo1.fType = lpCoolMenuItemInfo1.fType;
return InsertMenuItem(hPopMenu,lpCoolMenuItemInfo1.uPos,1,&MenuItemInfo1);
}
else
{
MenuItemInfo1.fMask = MIIM_TYPE | MIIM_DATA;
MenuItemInfo1.fType = MFT_OWNERDRAW;
MenuItemInfo1.wID = lpCoolMenuItemInfo1.wID;
MenuItemInfo1.cbSize = sizeof(MenuItemInfo1);
MMMENUITEMINFOPTR lpcmii1 = (MMMENUITEMINFOPTR) ::malloc(sizeof(lpCoolMenuItemInfo1));
//MenuItemInfo1.dwItemData = (unsigned long) lpcmii1;
MenuItemInfo1.dwTypeData = lpcmii1->szText;
MenuItemInfo1.cch = 256;
::strcpy (lpcmii1->szText, "Test 2" ); //lpCoolMenuItemInfo.szText) ;
//lpcmii->HotImageListIndex = lpCoolMenuItemInfo.HotImageListIndex;
//lpcmii->NormalImageIndex = lpCoolMenuItemInfo.NormalImageIndex;
lpcmii1->uPos = lpCoolMenuItemInfo1.uPos;
lpcmii1->fType = MenuItemInfo1.fType;
//lpcmii->cAccel = *(p+1);
::InsertMenuItem(hPopMenu,lpCoolMenuItemInfo1.uPos,1,&MenuItemInfo1);
}
I have tried doing this using OWNERDRAW and somehow the menu appears but without any text.
Thanks
|
|
|
|
|
I'm coding a winsock program, and I want to be able to take some of the data recieved, and print it to the screen. Since I recieved the data in a global function, I used code that looks like
((CMainDlg*)::AfxGetMainWnd())->SendData(sBuffer);
When I try to change the window text on a static control I get errors, as well as if I try to access any of the member variables. Any ideas?
-KMaz
|
|
|
|
|
There are several solutions. What I/O model does the program utilize? One importance of I/O model is knowing when and how the program receives the data. Afterward, you can design a way to transfer the incoming data to MFC's thread. One solution could be messages. Another solution could be a static data member and a critical section.
Kuphryn
|
|
|
|
|
kuphryn wrote:
What I/O model does the program utilize?
I am unfamiliar with the term I/O model....could you clear up what that means?
KMaz
|
|
|
|
|
I/O model symbolize how the program manage winsock I/O. Under a non-blocking I/O model, calls to WSARecv() and WSASend(), for example, returns immediately. There is not waiting.
Kuphryn
|
|
|
|
|
Another possibility is that your program is using different threads to do your thread I/O. If this is the case, it is not straightforward to update MFC UI objects in another thread.
Another possibility is that your receive function does not NULL terminate the received buffer.
|
|
|
|
|
I am developing an application in VC++ 6.0 with MFC(4.2, I think). Originally I was developing on Win98, but have since changed to WinXP. I notice that my dialogs, property sheets, etc. still have a Win98 look, even after I rebuilt on XP. I would like them to have the WinXP look, but I don't know how. Do I need to a newer version of Visual Studio, a new version of MFC perhaps?
Any help is much appreciated.
Thanks
Dermot
|
|
|
|
|
You need to either add a manifest file or add a manifest entry to your .RC file. I'm sure if you spend a few minutes searching the CP articles, you'll find the info you need.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Is there a way to receive a double click notice on a Static or Edit Control.
|
|
|
|
|
Yes, have you looked at NM_DBLCLK?
|
|
|
|
|
Hi, I am trying to get a handle to part of a loaded bitmap using CreateCompatibleBitmap but after I select this bitmap into a DC and BitBlt it always comes out as a black square. Maybe I don't understand exactly how the function is supposed to work. Here is my code:
HBITMAP LoadPartialBitmap(HWND hwnd)
{
HDC hdc, hdcMem;
HBITMAP hBitmapMain;
HBITMAP hBitmap;
hBitmapMain = (HBITMAP) LoadImage(NULL, "button.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hdc = GetDC(hwnd);
hdcMem = CreateCompatibleDC(hdc);
SelectObject(hdcMem, hBitmapMain);
BitBlt(hdc, 0, 0, 30, 30, hdcMem, 20, 20, SRCCOPY);
hBitmap = CreateCompatibleBitmap(hdc, 30, 30);
ReleaseDC(hwnd, hdc);
DeleteDC(hdcMem);
return hBitmap;
}
Am I using this function completely wrong?
|
|
|
|