c++ - Errors with resizing property sheet -


i'm trying make re-sizable property sheet using example http://support.microsoft.com/kb/300606. several errors in code don't know how overcome. created property sheet using class wizard on dialog. need re-size function mentioned in article. appreciated.

.cpp class

    #include "stdafx.h"     #include "geometry.h"     #include "geosheet.h"       // cgeosheet      implement_dynamic(cgeosheet, cpropertysheet)       cgeosheet::cgeosheet(uint nidcaption, cwnd* pparentwnd, uint iselectpage)     :cpropertysheet(nidcaption, pparentwnd, iselectpage)     {      }      cgeosheet::cgeosheet(lpctstr pszcaption, cwnd* pparentwnd, uint iselectpage)     :cpropertysheet(pszcaption, pparentwnd, iselectpage)     {      }      cgeosheet::~cgeosheet()     {     }       begin_message_map(cgeosheet, cpropertysheet)         on_command(idok, onok)     end_message_map()        // cgeosheet message handlers      void cgeosheet::onok()       {         cpropertysheet::onclose();     }      // overriding domodal() allows hook our callback     //    prop sheet creation     int cgeosheet::domodal()      {         // hook property sheet creation code         afx_oldpropsheetheader* psh = getpropsheetheader();         psh->dwflags |= psh_usecallback;         psh->pfncallback = xmnpropsheetcallback;         return cpropertysheet::domodal();     }       // function must static member function.      //callback allow set default window styles      //    property sheet     int cgeosheet ::xmnpropsheetcallback(hwnd hwnd, uint message, lparam lparam)     {         extern int callback afxpropsheetcallback(hwnd, uint message, lparam lparam);         // xmn: call mfc's callback         int nres = afxpropsheetcallback(hwnd, message, lparam);          switch (message)         {         case pscb_precreate:             // set our own window styles             ((lpdlgtemplate)lparam)->style |= (ds_3dlook | ds_setfont                 | ws_thickframe | ws_sysmenu | ws_popup | ws_visible | ws_caption);             break;         }         return nres;     } 

.h file

#pragma once    // cgeosheet  class cgeosheet : public cpropertysheet {     declare_dynamic(cgeosheet)  public:      cgeosheet(uint nidcaption, cwnd* pparentwnd = null, uint iselectpage = 0);     cgeosheet(lpctstr pszcaption, cwnd* pparentwnd = null, uint iselectpage = 0);     virtual ~cgeosheet();  protected:     declare_message_map()     //{{afx_msg(cmypropertysheet)         // note - classwizard add , remove member functions here.     afx_msg void onok();     int cgeosheet::domodal();     int cgeosheet ::xmnpropsheetcallback(hwnd hwnd, uint message, lparam lparam);     //}}afx_msg  }; 

i keep getting these errors.

geosheet.cpp(49) : error c2065: 'afx_oldpropsheetheader' : undeclared identifier geosheet.cpp(49) : error c2065: 'psh' : undeclared identifier geosheet.cpp(49) : error c3861: 'getpropsheetheader': identifier not found geosheet.cpp(50) : error c2065: 'psh' : undeclared identifier geosheet.cpp(50) : error c2227: left of '->dwflags' must point class/struct/union/generic type         type ''unknown-type'' geosheet.cpp(51) : error c2065: 'psh' : undeclared identifier geosheet.cpp(51) : error c2227: left of '->pfncallback' must point class/struct/union/generic type         type ''unknown-type'' 

edit modified domodal function according http://www.tech-archive.net/archive/vc/microsoft.public.vc.mfc/2005-09/msg00585.html; , single error.

code:

int cgeosheet::domodal()  {     // hook property sheet creation code     m_psh.dwflags |= psh_usecallback;     m_psh.pfncallback = xmnpropsheetcallback;// <--error     return cpropertysheet::domodal();  } 

error:

geosheet.cpp(50) : error c2440: '=' : cannot convert 'int (__cdecl *)(hwnd,uint,lparam)' 'pfnpropsheetcallback'     conversion requires reinterpret_cast, c-style cast or function-style cast 

you used cwndresizer class , can resize propertysheet.

in header file include cwndresizer class , make object of class. cwndresizer resizer;

in cpp file can resize control in propertysheet.

bool classname::oninitdialog() {

cpropertysheet::oninitdialog();     bool ok = false; ok = resizer.hook(this); assert(ok); 

// idc_polygons_list control id want resize

ok = resizer.setanchor(idc_polygons_list,anchor_left|anchor_top|anchor_bottom); assert(ok);    bok = resizer.setparent("cs",idc_static_groupbox2); assert(bok); 

}

for more detail follow link. http://www.codeproject.com/articles/125068/mfc-c-helper-class-for-window-resizing


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -