MingW & ProperySheet

This is a discussion on MingW & ProperySheet within the Windows Programming forums, part of the Platform Specific Boards category; I can not compile my project with MingW. Because says Implicit Declaration for PropertySheetA but I included prsht.h header also. ...

  1. #1
    Unregistered
    Guest

    MingW & ProperySheet

    I can not compile my project with MingW. Because says Implicit Declaration for PropertySheetA but I included prsht.h header also.

    (pure winapi, C project)

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I need a little more information. What version of mingw are you using?

  3. #3
    Unregistered
    Guest
    it is v2.95.3-6 and says undefined reference to PropertySheetA@4 in project.o. In fact I tried later Ken Fitlike's(FoosYerDos site owner) new header file for commctrl.h too. It contains prsht.h also. And added this header,

    #if defined __MINGW_H
    #define _WIN32_IE 0x0400
    #include <..\Added\Include\commctrl.h>
    #endif

    in this manner("Added" is in path). But I couln't do.

    (sorry it was not implicit declaration error, was undefined reference error.)

  4. #4
    Unregistered
    Guest
    My code is a clone of this code. MingW can not compile this too.
    Sorry for all long the code, i couldn't understand what is wrong.
    Also a friend can not compile this with VC++ 6.0 ?? The error seems the same thing.

    Code:
    // *************************************************************
    //   Created with BCX -- The BASIC To C Translator (ver 2.85)
    //      BCX (c) 1999, 2000, 2001, 2002 by Kevin Diggins
    // *************************************************************
    #include <windows.h>    // Win32 Header File
    #include <windowsx.h>   // Win32 Header File
    #include <commctrl.h>   // Win32 Header File
    #include <mmsystem.h>   // Win32 Header File
    #include <stdio.h>
    #include <string.h>
    #include <prsht.h>
    
    // *************************************************
    //            User Defined Constants
    // *************************************************
    
    #define PS_PAGES 3
    #define ID_BUTTON1 111
    #define IDD_PEOPLE 1001
    #define IDD_ANIMAL 1002
    #define IDD_BUILDING 1003
    #define IDM_EXIT 104
    #define IDM_ABOUT 300
    #define IC_PEOPLE 10001
    #define IC_ANIMAL 10002
    #define IC_BUILDING 10003
    
    // *************************************************
    //                System Variables
    // *************************************************
    
    char    BCX_STR [1024*1024];
    
    // *************************************************
    //            User Global Variables
    // *************************************************
    
    static  HWND  Form1;
    static  HWND  Button1;
    static  char   AppName[2048];
    static  char   Caption[2048];
    static  HINSTANCE  hInstance;
    static  PROPSHEETPAGE  psp[PS_PAGES];
    static  PROPSHEETHEADER  psh;
    static  HWND  hWndPropCtrl;
    
    // *************************************************
    //               Standard Prototypes
    // *************************************************
    
    char*   BCX_TmpStr(size_t);
    char*   str (double);
    
    // *************************************************
    //               User's Prototypes
    // *************************************************
    
    int     WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int);
    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
    void    FormLoad (HINSTANCE);
    int     FindFirstInstance (char *);
    int    CreatePropSheet (HWND);
    LRESULT CALLBACK PropSheetProc (HWND, UINT, WPARAM, LPARAM);
    
    //  Demonstrates use of Property Sheet
    //  written by Jef Rozenski
    
    // *************************************************
    //               Run Time Functions
    // *************************************************
    
    char *BCX_TmpStr (size_t Bites)
    {
    	static int   StrCnt;
    	static char *StrFunc [64];
    	StrCnt = (StrCnt + 1) & 63;
    	free  (StrFunc[StrCnt]);
    	return StrFunc[StrCnt] = (char*)calloc(Bites + 256, 1);
    }
    
    char *str (double d)
    {
    	char *strtmp;
    	strtmp = BCX_TmpStr(2048);
    	sprintf(strtmp,"% .16g",d);
    	return strtmp;
    }
    
    // *************************************************
    //             User Subs and Functions
    // *************************************************
    
    
    int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR CmdLine, int CmdShow)
    {
    	static  MSG  Msg;
    	static  WNDCLASS  wc;
    	memset(&Msg,0,sizeof(Msg));
    	memset(&wc,0,sizeof(wc));
    	hInstance=hInst;
    	strcpy(AppName,"PropSheetDemo");
    	if(FindFirstInstance(AppName))
    	{
    		return 0;
    	}
    //  register main window class
    //  Fill in window class structure with parameters that describe main window
    	wc.style=0;
    	wc.lpfnWndProc=WndProc;
    	wc.cbClsExtra=0;
    	wc.cbWndExtra=0;
    	wc.hInstance=hInst;
    	wc.hIcon=LoadIcon(NULL,IDI_WINLOGO);
    	wc.hCursor=LoadCursor(NULL,IDC_ARROW);
    	wc.hbrBackground=GetSysColorBrush(COLOR_BTNFACE);
    	wc.lpszMenuName="TreeViewMenu";
    	wc.lpszClassName=AppName;
    	RegisterClass(&wc);
    	FormLoad(hInstance);
    	while(GetMessage(&Msg,NULL,0,0))
    	{
    		TranslateMessage(&Msg);
    		DispatchMessage(&Msg);
    	}
    	return Msg.wParam;
    }
    
    
    LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
    	for( ;; )
    	{
    		if(Msg==WM_COMMAND)
    		{
    			for( ;; )
    			{
    				if(LOWORD(wParam)==ID_BUTTON1)
    				{
    					hWndPropCtrl=(HWND)CreatePropSheet(hWnd);
    					break;
    				}
    				if(LOWORD(wParam)==IDM_EXIT)
    				{
    					PostQuitMessage(0);
    				}
    				break;
    			}
    			break;
    		}
    		if(Msg==WM_DESTROY)
    		{
    			PostQuitMessage(0);
    			return 0;
    		}
    		break;
    	}
    	return DefWindowProc(hWnd,Msg,wParam,lParam);
    }
    
    
    void FormLoad (HINSTANCE hInst)
    {
    	strcpy(Caption,"Property Sheet Sample");
    	Form1=CreateWindow(AppName,Caption,WS_OVERLAPPEDWINDOW,0,0,300,200,NULL,(HMENU)NULL,hInst,NULL);
    	Button1=CreateWindowEx(0,"button","Show Properties",WS_CHILD|WS_TABSTOP|BS_PUSHBUTTON|WS_VISIBLE,25,10,200,30,Form1,(HMENU)ID_BUTTON1,hInst,NULL);
    	SendMessage(Button1,(UINT)WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),(LPARAM)MAKELPARAM(FALSE,0));
    	UpdateWindow(Form1);
    	ShowWindow(Form1,SW_SHOWNORMAL);
    }
    
    int FindFirstInstance (char *ApplName)
    {
    	static  HWND  hWnd;
    	memset(&hWnd,0,sizeof(hWnd));
    	hWnd=FindWindow(ApplName,NULL);
    	if(hWnd)
    	{
    		return     TRUE;
    	}
    	return FALSE;
    }
    
    int CreatePropSheet (HWND hWndParent)
    {
    	SendMessage(GetDlgItem(Form1,(UINT)ID_BUTTON1),(WPARAM)WM_SETTEXT,(LPARAM)0,(int)"Show Properties");
    	psp[0].dwSize=sizeof(PROPSHEETPAGE);
    	psp[0].dwFlags=0;
    	psp[0].hInstance=hInstance;
    	psp[0].pszTemplate=MAKEINTRESOURCE(IDD_PEOPLE);
    //psp[0].pszIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IC_PEOPLE));
    	psp[0].pfnDlgProc=(DLGPROC)PropSheetProc;
    	psp[0].pszTitle="?????";
    	psp[0].lParam=0;
    	psp[0].pfnCallback=NULL;
    	psp[1].dwSize=sizeof(PROPSHEETPAGE);
    	psp[1].dwFlags=PSP_USETITLE|PSP_HASHELP|PSP_USEHICON;
    //  this page has help button active
    //  if none of the pages has PSP_HASHELP
    //  then there will be no HELP button at all
    	psp[1].hInstance=hInstance;
    	psp[1].pszTemplate=MAKEINTRESOURCE(IDD_ANIMAL);
    //psp[1].pszIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IC_ANIMAL));
    	psp[1].pfnDlgProc=(DLGPROC)PropSheetProc;
    	psp[1].pszTitle="Animals";
    	psp[1].lParam=0;
    	psp[1].pfnCallback=NULL;
    	psp[2].dwSize=sizeof(PROPSHEETPAGE);
    	psp[2].dwFlags=PSP_USETITLE|PSP_HASHELP|PSP_USEHICON;
    //  this page has also help button active
    	psp[2].hInstance=hInstance;
    	psp[2].pszTemplate=MAKEINTRESOURCE(IDD_BUILDING);
    //psp[2].pszIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IC_BUILDING));
    	psp[2].pfnDlgProc=(DLGPROC)PropSheetProc;
    	psp[2].pszTitle="Buildings";
    	psp[2].lParam=0;
    	psp[2].pfnCallback=NULL;
    	psh.dwSize=sizeof(PROPSHEETHEADER);
    	psh.dwFlags=PSH_PROPSHEETPAGE|PSH_PROPTITLE;
    //  PSH_PROPTITLE includes "Properties" in the title
    	psh.hwndParent=hWndParent;
    	psh.hInstance=hInstance;
    	psh.pszIcon=NULL;
    	psh.pszCaption=(LPSTR)"Family";
    	psh.nPages=sizeof(psp)/sizeof(PROPSHEETPAGE);
    	psh.nStartPage=1;
    	psh.ppsp=(LPCPROPSHEETPAGE)&psp;
    	psh.pfnCallback=NULL;
    	return (PropertySheet(&psh));
    }
    
    
    LRESULT CALLBACK PropSheetProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
    	static char msgtxt[2048];
    	static  HWND  hIcon;
    	memset(&msgtxt,0,sizeof(msgtxt));
    	memset(&hIcon,0,sizeof(hIcon));
    	for( ;; )
    	{
    		if(Msg==WM_NOTIFY)
    		{
    			for( ;; )
    			{
    				if(((LPNMHDR)lParam)->code==PSN_APPLY)
    				{
    //
    //  when the apply button is pressed, the Property Sheet
    //  sends PSN_APPLY to all dialogs to make the next message
    //  visible, it is sent to the button instead of the form
    //
    					SendMessage(GetDlgItem(Form1,(UINT)ID_BUTTON1),(WPARAM)WM_SETTEXT,(LPARAM)0,(int)"PSN_APPLY");
    //
    //    check if all entries are OK (function not present in this demo)
    //
    //      IF AllOK() THEN
    					SetWindowLong(hWnd,DWL_MSGRESULT,PSNRET_NOERROR);
    //      ELSE
    //        SetWindowLong(hWnd,DWL_MSGRESULT,PSNRET_INVALID_NOCHANGEPAGE)
    //      ENDIF
    					break;
    				}
    				if(((LPNMHDR)lParam)->code==PSN_SETACTIVE)
    				{
    					SendMessage(Form1,(UINT)WM_SETTEXT,(WPARAM)0,(LPARAM)(int)"PSN_SETACTIVE");
    					break;
    				}
    				if(((LPNMHDR)lParam)->code==PSN_HELP)
    				{
    					SendMessage(Form1,(UINT)WM_SETTEXT,(WPARAM)0,(LPARAM)(int)"PSN_HELP");
    					break;
    				}
    				if(((LPNMHDR)lParam)->code==PSN_RESET)
    				{
    					SendMessage(Form1,(UINT)WM_SETTEXT,(WPARAM)0,(LPARAM)(int)"PSN_RESET");
    					SetWindowLong(hWnd,DWL_MSGRESULT,FALSE);
    //
    //   to distinguish from previous, this message
    //   is send to the button instead of the form
    //
    					break;
    				}
    				if(((LPNMHDR)lParam)->code==PSN_QUERYCANCEL)
    				{
    					SendMessage(GetDlgItem(Form1,(UINT)ID_BUTTON1),(WPARAM)WM_SETTEXT,(LPARAM)0,(int)"PSN_QUERYCANCEL");
    					SetWindowLong(hWnd,DWL_MSGRESULT,FALSE);
    					break;
    				}
    				if(((LPNMHDR)lParam)->code==PSN_KILLACTIVE)
    				{
    					SendMessage(GetDlgItem(Form1,(UINT)ID_BUTTON1),(WPARAM)WM_SETTEXT,(LPARAM)0,(int)"PSN_KILLACTIVE");
    					SetWindowLong(hWnd,DWL_MSGRESULT,FALSE);;
    				}
    				break;
    			}
    			break;
    		}
    		if(Msg==WM_COMMAND)
    		{
    			for( ;; )
    			{
    				if(LOWORD(wParam)>200)
    				{
    					sprintf(BCX_STR,"%s%s","controlID: ",str(LOWORD(wParam)));
    					strcpy(msgtxt,BCX_STR);
    					SendMessage(Form1,(UINT)WM_SETTEXT,(WPARAM)0,(LPARAM)(int)msgtxt);
    //  send notification of change
    //  this activates the APPLY button
    					PropSheet_Changed(GetParent(hWnd),hWnd);
    				}
    				break;
    			}
    		}
    		break;
    	}
    	return DefWindowProc(hWnd,Msg,wParam,lParam);
    }
    //----------------------------------------------------------------
    
    // Propsht.Rc
    
    #include <windows.h>
    
    10001  ICON   "people.ico"
    10002  ICON   "animal.ico"
    10003  ICON   "building.ico"
    
    1001 DIALOG 0, 0, 150, 200
    STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
    CAPTION "PEOPLE"
    FONT 8, "MS Sans Serif"
    BEGIN
        AUTOCHECKBOX    "male",     201, 10, 10, 80, 10
        AUTOCHECKBOX    "female",   202, 10, 20, 80, 10
        AUTOCHECKBOX    "children", 203, 10, 30, 80, 10
        LTEXT           "Note: this page has no HELP button", 204, 10, 60, 200, 12
    END
    
    1002 DIALOG 0, 0, 150, 200
    STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
    CAPTION "ANIMALS"
    FONT 8, "MS Sans Serif"
    BEGIN
        AUTOCHECKBOX    "cat"  , 211, 50, 50, 80, 10
        AUTOCHECKBOX    "dog"  , 212, 50, 60, 80, 10
        AUTOCHECKBOX    "horse", 213, 50, 70, 80, 10
        LTEXT           "Note: on this page HELP works", 213, 50, 100, 200, 12
    END
    
    1003 DIALOG 0, 0, 150, 200
    STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
    CAPTION "BUILDINGS"
    FONT 8, "MS Sans Serif"
    BEGIN
        AUTOCHECKBOX    "house"    , 221, 50, 100, 80, 10
        AUTOCHECKBOX    "garage"   , 222, 50, 110, 80, 10
        AUTOCHECKBOX    "dog house", 223, 50, 120, 80, 10
    END

  5. #5
    Unregistered
    Guest
    I founded "why?". Because;

    1. Lcc-win32 doesn't requires prsht header.(only 2 bytes empty file)

    2. Some libs doesn't linking just adding required header files. Must to add these manually. But I do not know which libs default for all the time exactly. Anyway, if application feign reluctance to run, I will try to add required libs manually from now on.

    Thanks to whom interested.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. MinGW thread-safe runtime libraries
    By Mario F. in forum C++ Programming
    Replies: 3
    Last Post: 08-21-2006, 09:15 AM
  2. Free compiler for commercial development? (mingw?)
    By kook44 in forum Windows Programming
    Replies: 8
    Last Post: 01-07-2006, 09:32 AM
  3. compiling mingw to enable timeSetEvent
    By underthesun in forum Windows Programming
    Replies: 2
    Last Post: 02-02-2005, 06:00 PM
  4. SDL and MinGW Studio
    By Vicious in forum Tech Board
    Replies: 0
    Last Post: 07-30-2004, 10:59 PM
  5. Convert Microsoft LIB to MingW compatible lib
    By tigs in forum Windows Programming
    Replies: 0
    Last Post: 07-20-2004, 07:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21