Thread: using structs

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    161

    using structs

    I defined structs some structs and I get errors that on the left of '->' must be a class/struct/union. I don't know what is the problem because there is a struct on the left side of '->'. Here is my code.

    I get errors where I used the info variable.
    Code:
    struct POINTAPI{long X;	long Y;}
    struct TXTFONT{short Height; short IndentX; short IndentY; short Left; short Top; short Width;}
    struct HDCINFO{long HDC; long Height; long Width;}
    struct OUTINFO{TXTFONT Font;  HDCINFO HDC; POINTAPI Point; long StrLen;short ScrollX;}
    [DllImport("gdi32.dll", EntryPoint="TextOutA")]
    static extern int32 TextOut (long hdc, long x, long y, char * lpString, long nCount);
    
    void _stdcall PrintText(char *pText, OUTINFO *info);
    BOOL APIENTRY DllMain( HANDLE hModule, 
                           DWORD  ul_reason_for_call, 
                           LPVOID lpReserved
    					 )
    {
        return TRUE;
    }
    void _stdcall PrintText(char *pText, OUTINFO *info){
    	long NextStart, I;
    	bool MoveIt;
    	for(I=0;I<info->StrLen;I++)
    	{
    		if(*pText==(char)10 || *pText == (char)13){info->Point.Y = info->Point.Y + info->Font.Height;
    			info->Point.X = info->Font.IndentX - (info->ScrollX * info->Font.Width);
    			if(info->Point.Y > (info->HDC.HDC-1)){break;}
    		}
    		else
    		{
    			if(info->Point.X > info->Font.IndentX){
    				if(info->Point.X > (info->HDC.Width-1)){
    					for( ;I < info->StrLen;I++){ if(*pText == (char)10){break}pText=pText+1;}
    					TextOut(info->HDC.HDC,info->Point.X,info->Point.Y,pText,1);
    			}
    			info->Point.X = info->Point.X + info->Font.Width;
    			pText=pText +1;
    		}
    	}
    }
    Any one know what is wrong?

    Thanx in advance!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Code:
    struct POINTAPI{long X;	long Y;}
    Don't you need a ; after the closing brace as well?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    161
    Thanx that worked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating array of structs
    By knirirr in forum C++ Programming
    Replies: 12
    Last Post: 06-18-2008, 08:30 AM
  2. Multidimentional structs + memcpy() == FAIL
    By Viper187 in forum C Programming
    Replies: 8
    Last Post: 06-18-2008, 02:46 AM
  3. packed structs
    By moi in forum C Programming
    Replies: 4
    Last Post: 08-20-2002, 01:46 PM
  4. ArrayLists + Inner Structs
    By ginoitalo in forum C# Programming
    Replies: 5
    Last Post: 05-09-2002, 05:09 AM
  5. Searching structs...
    By Sebastiani in forum C Programming
    Replies: 1
    Last Post: 08-25-2001, 12:38 PM