|
Sure, why not scale your values by 10 first?
Most screens aren't going to be wider than 1920px, if the client area of your control was to occupy the whole width, you still have fewer than 2000 uniquely displayable positions. It therefore follows that the smallest increment possible in such a situation is 0.05%
If you take a maxValue of (say) 3 billion then divide by 10 you get 3 hundred million. You would need your progress to advance by about 150,000 just to make the progress bar 1 pixel wider.
In short - you don't generally have a need for the progress bar range to be larger than about 2000. You just have to make sure that you scale curProgress and maxProgress to be under 214748364.
|
|
|
|
|
yes i get the max value for progressbar is 2147483647,
now here how can i calculate from which amount of step i need to stepit the progress bar to reach the end.
thanks.
|
|
|
|
|
I've just looked at the VS help for progress bars. I think you missed something in your research.
The max value for a progress bar is actually 65535 - The max value of a word. If you look at the message PBM_SETRANGE, you can see that it is used like this:
PBM_SETRANGE
wParam = 0;
lParam = MAKELPARAM(nMinRange, nMaxRange);
Since a LPARAM is 32 bits wide and it must hold both the min AND the max values, you only have 16 bits per field. It therefore follows that the nMaxRange is 65555.
In the example that comes with VS2010, a progBar is used to indicate the progress of reading a file.
I've include a couple of exceprts:
cb = GetFileSize(hFile, (LPDWORD) NULL);
SendMessage(hwndPB, PBM_SETRANGE, 0, MAKELPARAM(0, cb / 2048));
SendMessage(hwndPB, PBM_SETSTEP, (WPARAM) 1, 0);
do {
ReadFile(hFile, pchTmp, sizeof(char) * 2048, &cb, (LPOVERLAPPED) NULL);
.
.
.
SendMessage(hwndPB, PBM_STEPIT, 0, 0);
} while (cb);
|
|
|
|
|
Just use a scaling factor on your values for the slider.
I don't know what usage you will be using the slider, but if it is for a progress (of something) then add additional information about what is going on, because the slider will probably not move that much for large values.
Watched code never compiles.
|
|
|
|
|
I made a toolbar in my program, and on the main menubar, made a "View" menu item with a list of toolbars.
So I wrote CreateWindowEx to create the toolbar on program load. When you click the red X on the toolbar, I DestroyWindow, and the toolbar is gone. Then if I go to View, and click the toolbar, I run CreateWindowEx and make the Toolbar again.
Symptom:
When I make the toolbar the 2nd time, the toolbar window is not active. I can load stuff in it, but can't use the red x or the treeview inside the window. I get get focus on the window to use it.
Question:
I'm not sure what I did wrong, or if I'm just missing something in one of the Proc's.
|
|
|
|
|
That was a really bad idea there. I went back to hide and show, and figured out how to avoid the WM_DESTROY message when clicking the close button on the window bar.
|
|
|
|
|
could you post the CreateWindowEx() code snippet
|
|
|
|
|
It turned out to be a big mess. The Bool bRegister was a unsuccessful attempt to unregister the class after it was created. I thought if I could create the class, create the window, that I could destroy the window, and unregister the class to create a clean slate, and start the process again.
On the 2nd time around, the window would paint, but it would not respond. When I took the other toolbar and dragged it across the regenerated toolbar, the regenerated toolbar would not paint again and dissappear. So I added the WS_CLIPSIBLINGS, and upon regeneration, no window at all.
So I went back to show and hide, and added a return 1 to the WM_CLOSE in the Windows Proc, to cancel destroying the window, and to just run ShowWindow and update the checkbox in the main menu.
HWND _project_Explorer_Create( HWND hWndMain, HINSTANCE hInstance, HWND hMDIClientArea, HWND hWndStatusBar )
{
hProjectExplorer_Instance = hInstance;
LoadString( hInstance, IDM_PROJECT_EXPLORER_CLASS, sz_ProjectExplorer_Class, MAX_LOADSTRING );
WNDCLASSEX toolWindow;
toolWindow.cbSize = sizeof(WNDCLASSEX);
if ( !GetClassInfoEx( hInstance, sz_ProjectExplorer_Class, &toolWindow ) ) {
toolWindow.style = CS_HREDRAW | CS_VREDRAW;
toolWindow.lpfnWndProc = _project_Explorer_WndProc;
toolWindow.cbClsExtra = 0;
toolWindow.cbWndExtra = 0;
toolWindow.hInstance = hInstance;
toolWindow.hIcon = 0;
toolWindow.hCursor = 0;
toolWindow.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
toolWindow.lpszMenuName = 0;
toolWindow.lpszClassName = sz_ProjectExplorer_Class;
toolWindow.hIconSm = 0;
RegisterClassEx( &toolWindow );
}
RECT winRect, statusBarRect;
INT winWidth, winHeight, tbWidth, tbHeight, sbWidth, sbHeight;
if(GetWindowRect( hMDIClientArea, &winRect)) {
winWidth = winRect.right - winRect.left;
winHeight = winRect.bottom - winRect.top;
GetWindowRect( hWndStatusBar, &statusBarRect );
sbWidth = statusBarRect.right - statusBarRect.left;
sbHeight = statusBarRect.bottom - statusBarRect.top;
tbWidth = 250;
tbHeight = (INT)floor(( (float)winHeight * (float).60 ) - 1 );
hWnd_ProjectExplorer = CreateWindowEx(
WS_EX_TOOLWINDOW,
sz_ProjectExplorer_Class,
TEXT( "Project Explorer" ),
WS_CHILD | WS_SYSMENU | WS_CAPTION | WS_VISIBLE | WS_CLIPSIBLINGS,
winWidth - tbWidth - 1, 1,
tbWidth, tbHeight,
hWndMain,
NULL,
GetModuleHandle(0),
NULL
);
ShowWindow( hWnd_ProjectExplorer, SW_SHOW);
UpdateWindow( hWndMain );
}
return hWnd_ProjectExplorer;
}
|
|
|
|
|
thanks for ur reply,
use this code snippet
..........
static bool reg =false;
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
if( reg )
{
UnregisterClass(szWindowClass, hInstance );
}
if (!RegisterClassEx(&wcex))
{
MessageBox(NULL,
_T("Call to RegisterClassEx failed!"),
_T("Win32 Guided Tour"),
NULL);
return 1;
}
reg = true;
.............
|
|
|
|
|
Well thanks, but I'm not going to try that. I don't see the point of it. I'd rather have an explanation as to why I can't destroy a window and it's class and recreate it like an MDI Child Window.
|
|
|
|
|
Toolbar with treeview?
What kind of toolbar you are referring to? Are you sure you are creating a toolbar? Maybe it is a tool window?
Could you please post a snippet showing how you create this toolbar.
JohnCz
|
|
|
|
|
It's a tool window, I just called it a toolbar so folks got the bigger picture of what I was trying to do.
So far so good, I have my MDI frame, and the 2 sidebars (toolbars) on the left. They size correctly, move and resize upon mid resize. The hide and show works good.
Next phase is to dock them, but I need to tighten up the program first, and do an initial alpha test release. Hopefully this week.
|
|
|
|
|
I can do the following:
boost::scoped_ptr<MyClass> class;
class->DoSomething();
class.reset(new MyClass);
Doesn't it go against RAII? I keep reading that scoped_ptr is RAII but i can use object before it is initialized.
Thanks
|
|
|
|
|
and what happens when you run that?
|
|
|
|
|
He won't even get as far as compiling it, let alone running it
|
|
|
|
|
I got a segmentation fault, as expected.
Could you please explain.
|
|
|
|
|
you declared a pointer, but never pointed it to an object. what's to explain?
|
|
|
|
|
Is the purpose of RAII not to allow such a thing?
Currently i am acquiring a resource but do not initialize it.
|
|
|
|
|
elelont2 wrote: Currently i am acquiring a resource but do not initialize it.
but you're not acquiring any resource; you're just declaring an uninitialized pointer. the scoped_ptr c'tor allows you to defer allocation - but you do need to allocate it at some time, before you start using it.
look at boost's examples[^]:
boost::scoped_ptr<Shoe> x(new Shoe);
they allocate (acquire) the object while declaring the pointer.
also:
class MyClass {
boost::scoped_ptr<int> ptr;
public:
MyClass() : ptr(new int) { *ptr = 0; }
int add_one() { return ++*ptr; }
};
they declare the pointer, but defer allocation until the 'add_one' call.
|
|
|
|
|
So, apart from the fact you'll never be able to call an object class (naughty, naughty) how does writing:
boost::scoped_ptr<any_old_iron> ptr;
leave you with an unitialised object? Or in other words what's not initialised in that statement?
If you can work that out you'll see that scoped_ptr supports RAII (or as I prefer to call it these days scoped based resource management, SBRM) perfectly.
Cheers,
Ash
|
|
|
|
|
I have an uninitialized object in that case and ptr->Func() will probably crash?
|
|
|
|
|
ny_old_iron class will be uninitialized. How is it initialized?
Also, what do you mean by "object class"?
RAII says that the object is initialized during acquisition. scoped_ptr is supposed to support RAII but it allows to defer allocation, which means that the object pointed by the scoped_ptr is uninitialized.
Therefore i would say that scoped_ptr is not RAII.
|
|
|
|
|
When in the .net platform, it is easy to operate database, but when in the unmanaged c++,
how to operate the sql server 2005?
Can someone give me a example link?
|
|
|
|
|
|
you can connect your table to display in data format to make possible for it. So Sql(Sequence query language) to use,we do in edit,delete and update our data into the table.
|
|
|
|
|