Hi all~

Happy New Year!

I have new ProgressBar same as stadard Win32-ProgressBar. ^^;

I made ProgressBar procedure,
- first method, inserted to project
- secode method, made new "progress.dll" then LoadLibrary...

In ProgressBar procedure


case WM_PAINT:
hdc = BeginPaint( hWnd, &ps );
GetClientRect( hWnd, &rc );
rc.left ++; rc.right--; rc.top++; rc.bottom--;
CopyRect( &txtRect, &rc );
//
hbr = CreateSolidBrush( BackColor );
FillRect( hdc, &rc, hbr );
DeleteObject( hbr );
//
hbr = CreateSolidBrush( BarColor );
rc.right = nCurrentPos*rc.right/100;
FillRect( hdc, &rc, hbr );
//
if( bShowPercent == TRUE ){
oldPos = SetBkMode( hdc, TRANSPARENT );
if( nCurrentPos < 50 )
oldCol = SetTextColor( hdc, RGB( ~(BackColor&0xff), ~((BackColor&0xff00)>>8), ~((BackColor&0xff0000)>>16) ) );
else
oldCol = SetTextColor( hdc, RGB( ~(BarColor&0xff), ~((BarColor&0xff00)>>8), ~((BarColor&0xff0000)>>16) ) );
wsprintf(buf, "%3d%%", nCurrentPos );
DrawText( hdc, buf, lstrlen(buf), &txtRect, DT_CENTER|DT_VCENTER );
SetTextColor( hdc, oldCol );
SetBkMode( hdc, oldPos );
}
//
DeleteObject( hbr );
//
EndPaint( hWnd, &ps );
break;



In My rc file...


CONTROL "",SUB_PROGRESS,"MYCLS32_PROGRESS", 0x0, 9, 12, 334, 12
CONTROL "",TOTAL_PROGRESS,"MYCLS32_PROGRESS", 0x0, 9, 26, 334, 12,WS_EX_STATICEDGE


then
invoke DialogBoxParam, ...

and so, on..

in DialogBox proc, in "C" ( sorry, I think asm equals C, C equal asm!!. ^^; )




case WM_INITDIALOG:
hProgressBar = GetDlgItem( hDlg, SUB_PROGRESS );
SendMessage( hProgressBar, PBM_SETBARCOLOR, 0, (LPARAM)(COLORREF)RGB (0,255,0) );
hTotalProgressBar = GetDlgItem( hDlg, TOTAL_PROGRESS );
SendMessage( hTotalProgressBar, PBM_SETBARCOLOR, 0, (LPARAM)(COLORREF)RGB(0,0,255) );



===============

Everything OK,

as u see above, I want to see it "GREEN" and "BLUE" but it doesn't

when I changed className "MYCLS32_PROGRESS" to standard "msctls_progress32" It works!!! :sweat:


How Can I solve this???:confused:

I Know, Dll's shared memory, but It's private data section copied separatly...
but "msctls_progress32" 's progressBar works!!!
I can't understand this...

If I use just ONE ProgressBar per thread, or process, that will work... may be
but, same process ( same thread ) how...does it works?

How does "msctls_progress32" organized?:confused:
Posted on 2004-01-24 09:17:54 by muzidowa
Off-topic: Kong Hei Fat Choy!


What's the code that handles PBM_SETBARCOLOR? Did you write this code? Do you pass it to msctls_progress32?
Posted on 2004-01-24 09:25:00 by AmkG
Yes!!

I passed it msctls_progess32, then It works ( GREEN and BLUE color )

but when I pass it to my own progressbar I does not ( only BLUE )
Posted on 2004-01-24 09:29:34 by muzidowa
Err I mean does YOUR progress bar trap PBM_SETBARCOLOR.... something like:


/*pseudo-code*/
case PBM_SETBARCOLOR:
func_pointer = (something *)() GetClassLong(msctls_progress32, GCL_WindowProc);
*func_pointer (hWnd, uMsg, wParam,lParam)...

aarg I suck at C....


;Still pseudo-code but asm-style
casePBM_SETBARCOLOR:
Invoke GetClassLong, msctls_progress32,GCL_WINDOWPROC
jmp near ptr [eax]


i.e. did you subclass your progressbar?

From the looks of it you did not, so yeah..... does your progressbar handle PBM_SETBARCOLOR??
Posted on 2004-01-24 09:36:49 by AmkG
sure!!

It processed all standard PBM_XXXX message,
so, my progressbar works well

But, As u see below,
my vars used between two "GREEN" and "BLUE" progressBar
and last modified "BLUE" color only applied!!!

PBM_SETBARCOLOR ( green )
PBM_SETBARCOLOR ( blue ) ========> this only applied!!! ===> my problem is this!!



static int nIncrement; // PBM_DELTAPOS
static int nCurrentPos; // PBM_GETPOS, PBM_SETPOS
static int iLowLimit; // PBM_SETRANGE, PBM_SETRANGE32
static int iHighLimit; // PBM_SETRANGE, PBM_SETRANGE32
static COLORREF BarColor; // PBM_SETBARCOLOR
static COLORREF BackColor; // PBM_SETBKCOLOR
static int nStepInc; // PBM_SETSTEP, PBM_STEPIT

static boolean bShowPercent;

...
case PBM_SETBARCOLOR:
oldCol = BarColor;
if( (COLORREF)lParam == CLR_DEFAULT ){
BarColor = defBarColor;
}else{
BarColor = (COLORREF)lParam;
}
InvalidateRect( hWnd, NULL, TRUE );
return oldCol;

Posted on 2004-01-24 09:45:29 by muzidowa
The parameters for the progress bar have to be stored in the window properties - looks like maybe you are using the same parameters for all progress bars?

If this is the problem could use GetProp/SetProp to store parameters.
Posted on 2004-01-24 10:02:22 by bitRAKE
Ah I see. Bar_Color is static, so you have only ONE variable for ALL progress bars. The fact that dll's have a unique private data section does NOT work because it is unique on a per-application basis.... since the two progress bars are in the same application, you get ONE Bar_Color register for BOTH progress bars.

To assign a memory location that is bound to a particular window, you must change your class registration a bit to allocate memory for all windows of that class (can't remember what the term's called though), and use GetWindowLong and SetWindowLong to save memory there. If you have a WinAPI reference, just look up GetWindowLong and SetWindowLong and the two articles should have something about how to allocate memory that is bound to each window - this memory is accessed by passing a negative value to Get/SetWindowLong. You can then use this memory as a sort of "private class variable" which your PBM_SETBARCOLOR and WM_PAINT "methods" can use.
Posted on 2004-01-24 10:03:58 by AmkG
Hmm didn't know about GetProp/SetProp...... how do these work bitRAKE??
Posted on 2004-01-24 10:06:17 by AmkG
thanks, AmkG

It works well~..

as u recommed I used



SetWindowLong, hWnd, GWL_USERDATA, pMyData
Posted on 2004-01-24 11:07:00 by muzidowa
I assume you allocate pMyData for each window that's created? That's another and perfectly valid way of doing it.

OT: Looks like I'm not as rusty in programming as I thought. ;)
Posted on 2004-01-24 19:14:31 by AmkG