Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PAGER CONTROLS ARE A WIN32 FUCKING MYTH

192 views
Skip to first unread message

Giuliano Suminsky

unread,
Dec 11, 2011, 8:10:28 AM12/11/11
to
Dammit, Its been 2 days since Im trying to use a goddamit pager
control, that shit wont show up! The only thing I get is my contained
buttons to disappear behind a blank quad, and get resized by the pager
control size, but theres no arrows, and yes, I AM processing
PGN_CALCSIZE(funny thing is it asks for width only, never height(its a
Horz pager, but anyway..))
Heres my code(note its only a teste for see the damn thing):

HWND hB1 = CreateWindow( WC_BUTTON,
TEXT("ok"),
WS_CHILD|WS_VISIBLE,
10, 10, 100, 100,
hMainFrameWindow, (HMENU)331,
NULL,
NULL );


HWND hB2 = CreateWindow( WC_BUTTON,
TEXT("apply"),
WS_CHILD|WS_VISIBLE,
111, 10, 100, 100,
hMainFrameWindow, (HMENU)333,
NULL,
NULL );

HWND hB3 = CreateWindow( WC_BUTTON,
TEXT("cancel"),
WS_CHILD|WS_VISIBLE,
202, 10, 100, 100,
hMainFrameWindow, (HMENU)332,
NULL,
NULL );





INITCOMMONCONTROLSEX comCtrlParam;
comCtrlParam.dwSize = sizeof(INITCOMMONCONTROLSEX);
comCtrlParam.dwICC = ICC_PAGESCROLLER_CLASS;
if(!InitCommonControlsEx( &comCtrlParam ) )
WMMERROR( GetLastError );

//create a pager ctrl:
HWND hPager = CreateWindow( WC_PAGESCROLLER,
NULL,
WS_CHILD|WS_VISIBLE|PGS_AUTOSCROLL|PGS_DRAGNDROP|PGS_VERT,
10, 10, 310, 200,
hMainFrameWindow, (HMENU)333,
pWndProcGFrameInstance->hAppInstance,
NULL );
if( !hPager )
WMMERROR( GetLastError() );

Pager_SetChild( hPager, hB1 );
Pager_SetChild( hPager, hB2 );
//Pager_SetChild( hPager, hB3 );


...

heres the windows procedure:
case WM_NOTIFY:

switch( ((LPNMHDR)lParam )->code) {

case PGN_CALCSIZE:{

LPNMPGCALCSIZE pCS = (LPNMPGCALCSIZE)lParam;
switch( pCS->dwFlag ){

case PGF_CALCHEIGHT:

pCS->iHeight = 100;
return 0;

case PGF_CALCWIDTH:
pCS->iWidth = 360;
return 0;
}


}return 0;

default:
return 0;
}

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
It creates 3 buttons, than the pager, than use the set child pager
macro..pretty standard
Should I be doing anything else?
Someone alredy have succefuly created a pager control?
Please, I beg your help

Giuliano Suminsky

unread,
Dec 11, 2011, 11:03:10 AM12/11/11
to
Ok, somethings I figured out (STILL NOT SOLVED):
The pager handles just ONE window..Second MSDN it says it doesnt need
be a WS_CHILD window, but if it is, it HAS to be a pager child..(weird
it dont need to be a child)
So, I created a toolbar with 3 buttons, now the pager and the toolbar
are displayed fine, but the damn toolbar doesnt scroll!(I created 3
large buttons, so it does need scrolling)
Im getting the pager scroll message/notification, and MSDN says I dont
need do anything about scrolling....
So im clueless again...
This is my new code:

INITCOMMONCONTROLSEX comCtrlParam;
comCtrlParam.dwSize = sizeof(INITCOMMONCONTROLSEX);
comCtrlParam.dwICC = ICC_PAGESCROLLER_CLASS;
if(!InitCommonControlsEx( &comCtrlParam ) )
WMMERROR( GetLastError );

//create a pager ctrl:
HWND hPager = CreateWindow( WC_PAGESCROLLER,
NULL,
WS_CHILD|WS_VISIBLE|PGS_HORZ|WS_DLGFRAME,
10, 10, 300, 100,
hMainFrameWindow, (HMENU)333,
pWndProcGFrameInstance->hAppInstance,
NULL );
if( !hPager )
WMMERROR( GetLastError() );


HWND hWndToolbar = CreateWindowEx( 0, TOOLBARCLASSNAME,
NULL,
WS_CHILD |WS_VISIBLE,
0, 0, 300, 100,
hPager, NULL,
pWndProcGFrameInstance->hAppInstance,
NULL);

if (hWndToolbar == NULL)
WMMERROR( GetLastError );

TBBUTTON tbButtons[3] =
{
{I_IMAGENONE, 301, TBSTATE_ENABLED, BTNS_CHECK, {0}, 0,
(INT_PTR)L"Meu pau no meio do teu cuzinho." },
{I_IMAGENONE, 302, TBSTATE_ENABLED, BTNS_CHECK, {0}, 0,
(INT_PTR)L"Bucetinha cagada no cu da mae."},
{I_IMAGENONE, 303, TBSTATE_ENABLED, BTNS_CHECK, {0}, 0,
(INT_PTR)L"Feliz foi o morto que nao morreu."}
};

// Add buttons.
SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE,
(WPARAM)sizeof(TBBUTTON), 0);
SendMessage(hWndToolbar, TB_ADDBUTTONS, (WPARAM)3,
(LPARAM)&tbButtons);


// SendMessage(hWndToolbar, TB_AUTOSIZE, 0, 0);
// ShowWindow(hWndToolbar, TRUE);
Pager_SetChild( hPager, hWndToolbar );


Pager_SetButtonSize( hPager, 20 );
Pager_SetBkColor( hPager, 0x000011ff);

...

and the wndproc:
case WM_NOTIFY:

switch( ((LPNMHDR)lParam )->code) {

case PGN_CALCSIZE:{

LPNMPGCALCSIZE pCS = (LPNMPGCALCSIZE)lParam;
switch( pCS->dwFlag ){

case PGF_CALCHEIGHT:

pCS->iHeight = 100;
return 0;

case PGF_CALCWIDTH:
pCS->iWidth = 1500;
return 0;

}


}return 0;
//case PGN_SCROLL:{

// LPNMPGSCROLL pScroll = (LPNMPGSCROLL)lParam;
//
// switch(pScroll->iDir){
//
// case PGF_SCROLLLEFT:
// case PGF_SCROLLRIGHT:
// case PGF_SCROLLUP:
// case PGF_SCROLLDOWN:
//
// pScroll->iScroll = 20;IT DOES GET HERE EACH TIME I PRESS THE
PAGER ARROWS **************************************!!!
// //pScroll->
//
// break;
// }
// }
//
// return 1;

default:
return 0;
}

Christian ASTOR

unread,
Dec 11, 2011, 12:17:56 PM12/11/11
to
Giuliano Suminsky a écrit :

> Someone alredy have succefuly created a pager control?


A sample =>

// Generic Toolbar Buttons

TBBUTTON tbb[] = {
{STD_CUT, 0, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_COPY, 1, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_PASTE, 2, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_UNDO, 3, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_REDOW, 4, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_DELETE, 5, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_DELETE, 6, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_FILENEW, 7, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_FILEOPEN, 8, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_FILESAVE, 9, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_PRINTPRE, 10, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_PROPERTIES, 11, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_HELP, 12, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_FIND, 13, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_REPLACE, 14, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_PRINT, 15, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0}
};

int nButtonCount = sizeof(tbb)/sizeof(tbb[0]);

// Initialization

INITCOMMONCONTROLSEX icc;
icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
icc.dwICC = ICC_PAGESCROLLER_CLASS; InitCommonControlsEx(&icc);

// Windows creation

hWndPager = CreateWindowEx(0, WC_PAGESCROLLER, NULL,
WS_BORDER | WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
PGS_HORZ, 100, 100, 250, 32, hWnd, (HMENU) 0, hInst, NULL);

hWndToolbar = CreateToolbarEx(hWndPager, WS_CHILD | WS_VISIBLE |
TBSTYLE_FLAT | CCS_NORESIZE, 100, 6, (HINSTANCE)HINST_COMMCTRL,
IDB_STD_LARGE_COLOR,(LPCTBBUTTON)tbb, nButtonCount, 0, 0, 0, 0,
sizeof(TBBUTTON));

SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
SendMessage(hWndPager, PGM_SETCHILD, 0, (LPARAM)hWndToolbar);
SendMessage(hWndPager, PGM_RECALCSIZE, 0, 0L);


// Notifications

case WM_NOTIFY:
{
LPNMHDR pnmh = (LPNMHDR) lParam;
switch(pnmh->code)
{
case PGN_CALCSIZE:
{
LPNMPGCALCSIZE pCalcSize = (LPNMPGCALCSIZE)lParam;
switch(pCalcSize->dwFlag)
{
case PGF_CALCWIDTH:
{
SIZE size;
SendMessage(hWndToolbar, TB_GETMAXSIZE, 0, (LPARAM)&size);
pCalcSize->iWidth = size.cx;
}
break;
}
}
break;
case PGN_SCROLL:
{
LPNMPGSCROLL pnms = (LPNMPGSCROLL) lParam;
pnms->iScroll = 30;
}
break;
}
}
break;

Giuliano Suminsky

unread,
Dec 11, 2011, 1:47:05 PM12/11/11
to
Ha! Thanks a lot man!
The problem was only the CCS_NORESIZE style...I didnt realize toolbar
where a commom control, so my toolbar was getting croped by the pager
size, so no scrolling was possible at all...
BTW, taking a look at MSDN theres no way to tell toolbar are commom
controls...(if you use a commom control style in controls like
button(not commom) you get screwed up)..

Thanks a lot =D

Giuliano Suminsky

unread,
Dec 11, 2011, 1:41:44 PM12/11/11
to

Deanna Earley

unread,
Dec 12, 2011, 6:13:18 AM12/12/11
to
They're all part of the common controls library (if using XP themes).
Before that only a few were provided by Windows itself (like button,
edit, static, etc)

--
Deanna Earley (dee.e...@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
0 new messages