progressbar erstellen u verwenden....
-
guckst du hier: http://www.functionx.com/win32/ProgressBars.htm
-
hi!
ich hab eine win32 konsolenanwendung...und kann mit ressourcen dann ja net arbeiten, deshalb erstell ich so eine progressbar so:CreateWindowEx(0, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, 20, 20, 260, 17, hWndDlg, NULL, hInst, NULL);
wie kann ich da jetzt bei der progressbar den wert des balkens verändern?
cu
-
send message alle mit PBM_xxxx
PBM_SETPOS Message -------------------------------------------------------------------------------- Sets the current position for a progress bar and redraws the bar to reflect the new position. Syntax To send this message, call the SendMessage function as follows. lResult = SendMessage( // returns LRESULT in lResult (HWND) hWndControl, // handle to destination control (UINT) PBM_SETPOS, // message ID (WPARAM) wParam, // = (WPARAM) (int) nNewPos; (LPARAM) lParam // = 0; not used, must be zero ); Parameters nNewPos Signed integer that becomes the new position. lParam Must be zero. Return Value Returns the previous position. Message Information Minimum DLL Version comctl32.dll version 4.00 or later Header commctrl.h Minimum operating systems Windows NT 4.0, Windows 95
-
1.) Warum kannst du bei Konsolen-Anwendungen keine Ressourcen verwenden?
2.) Worauf willst du die Progressbar überhaupt anzeigen?
-
#include <commctrl.h> #pragma comment(lib,"Comctl32.lib") int main() { HWND hProgress; // ProgressBar erzeugen //InitCommonControls(); INITCOMMONCONTROLSEX InitCtrlEx; InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCtrlEx.dwICC = ICC_PROGRESS_CLASS; InitCommonControlsEx(&InitCtrlEx); hProgress = CreateWindowEx(0, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, 20, 20, 260, 17, NULL, NULL, NULL, NULL); // Schrittläge einstellen SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM (0, 100)); SendMessage(hProgress, PBM_SETSTEP, (WPARAM) 10, 0); // mit jedem Schritt 10% weiter SendMessage(hProgress, PBM_STEPIT, 0, 0); // Befehl um einen Schritt zu machen
irgendwie tut sich da nix;-(
hmmcu
-
Wird überhaupt eine Progress-Bar angezeigt?
-
nö
-
lol dann sag das doch gleich. du folltrottel.
das liegt daran das du WS_CHILD angibst, aber kein Parent hast. Nimm z.B. WS_POPUP anstatt WS_CHILD
-
ltd. documentation sollte gehen
PBM_SETPOS mal probieren
-
vdittrich schrieb:
ltd. documentation sollte gehen
PBM_SETPOS mal probieren
hab keien ressource hinzugefügt muss man auch noch erwähnen! wohin mit PBM_SETPOS ?
cu
-
danke! schaut aber ne grad schön aus so eine progressbar alleine ohne window;-(
cu
-
hProgress = CreateWindowEx(0, PROGRESS_CLASS, NULL,
WS_CHILD | WS_VISIBLE | PBS_SMOOTH,
20, 20, 260, 17,
NULL, NULL, NULL, NULL);erst mal hProgress != 0 damit es auch erstllt wurde
-
vdittrich schrieb:
hProgress = CreateWindowEx(0, PROGRESS_CLASS, NULL,
WS_CHILD | WS_VISIBLE | PBS_SMOOTH,
20, 20, 260, 17,
NULL, NULL, NULL, NULL);erst mal hProgress != 0 damit es auch erstllt wurde
hab ein handle hProgress auf createWindowEx!!!
wie kann ich ein fenster erstellen wo die progressbar drinnen ist?cu
-
so soll die progressbar in dem fenster sein...
http://www.functionx.com/win32/images/progressbar1.gifbrauch i da ne dialogbox noch? nun is halt die frage wie tut man die progressbar da rein..
cu
-
ich würde sagen dem surf sollte man nicht helfen. der rafft eh nichts.
-
haha
-
wie wärs erstmal mit nem normalen window über createWindow und dann die progressbar da als child rein(auch wieder über createWindow)...
-
////////////////////// Hautfenster erstellen //////////////////////////////// HWND hWndMain; /* Handle auf unser Hauptfenster */ WNDCLASS wc; /* Struktur zum Fensterklassen bescheiben */ wc.style = CS_HREDRAW | CS_VREDRAW; /* Repaint bei Fenstergößenänderung */ wc.lpfnWndProc = WndProc; /* Nachrichtenbearbeitungs Funktion */ wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; /* Programm ID (Parameter von WinMain)*/ wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wc.lpszClassName = szAppName; /* Klassenname (bei uns = Programmname) */ wc.lpszMenuName = NULL; RegisterClass(&wc); /* Fensterklasse anmelden */ hWnd = CreateWindow(szAppName, /* Fenster erstellen */ "Titelleiste", WS_OVERLAPPEDWINDOW, /* Fensterstil */ CW_USEDEFAULT, /* X-Position */ CW_USEDEFAULT, /* Y-Position */ CW_USEDEFAULT, /* Breite */ CW_USEDEFAULT, /* Höhe */ NULL, NULL, hInstance, /* Programm ID */ NULL); ShowWindow(hWnd, iCmdShow); /* Fenster anzeigen */ UpdateWindow(hWnd); /* Und ein Repaint */ /////////////////////// Progressbar im Hauptfenster erstellen //////////////// HWND hProgress; // ProgressBar erzeugen //InitCommonControls(); INITCOMMONCONTROLSEX InitCtrlEx; InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCtrlEx.dwICC = ICC_PROGRESS_CLASS; InitCommonControlsEx(&InitCtrlEx); hProgress = CreateWindowEx(0, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, 20, 20, 260, 17, NULL, NULL, NULL, NULL); // Schrittläge einstellen SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM (0, 100)); SendMessage(hProgress, PBM_SETSTEP, (WPARAM) 10, 0); // mit jedem Schritt 10% weiter SendMessage(hProgress, PBM_STEPIT, 0, 0); // Befehl um einen Schritt zu machen
hab bei der progressbar den parameter: WS_CHILD drinn! müsste passen? wie soll ich den balken verändern mit: PBM_SETPOS oder PBM_STEPIT ?
-
Du könntest auch einfach einen Dialog als Ressource zusammenklicken und den dann aufrufen, falls dir das lieber ist.
PBM_SETPOS oder PBM_STEPIT
Mit PBM_SETPOS kannst du eben direkt den Wert angeben, der gesetzt werden soll, mit PBM_STEPIT wird einfach nur einen Schritt weitergezähl (was in den meisten Fällen wohl reicht)
-
flenders schrieb:
Du könntest auch einfach einen Dialog als Ressource zusammenklicken und den dann aufrufen, falls dir das lieber ist.
PBM_SETPOS oder PBM_STEPIT
Mit PBM_SETPOS kannst du eben direkt den Wert angeben, der gesetzt werden soll, mit PBM_STEPIT wird einfach nur einen Schritt weitergezähl (was in den meisten Fällen wohl reicht)
ach ich mach das mal lieber ohne ressource! dann test ich das mal mit PBM_SETPOS...
frage zum haupfenster:
was mach ich mit hInstance, wenn ich da kein WinMain habe?wc.hInstance = hInstance; /* Programm ID (Parameter von WinMain)*/
cu