InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
#include <windows.h>
#include <stdint.h>
#include <stdbool.h>
#include "system_setup.h"
#include "control_page.h"
LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){
static int current_page = 0;
switch(msg){
case WM_COMMAND:
switch(wp){
case HOME_PAGE:
InvalidateRect(hWnd, NULL, TRUE);
main_menu_page(hWnd);
UpdateWindow(hWnd);
break;
case MOTORS_PAGE:
InvalidateRect(hWnd, NULL, TRUE);
motors_page(hWnd);
UpdateWindow(hWnd);
break;
case ELECTRICAL_PAGE:
InvalidateRect(hWnd, NULL, TRUE);
electrical_page(hWnd);
UpdateWindow(hWnd);
break;
case WEATHER_PAGE:
InvalidateRect(hWnd, NULL, TRUE);
weather_page(hWnd);
UpdateWindow(hWnd);
break;
case LED_CONTROL_PAGE:
InvalidateRect(hWnd, NULL, TRUE);
led_control_page(hWnd);
UpdateWindow(hWnd);
break;
case SERVO_MOTOR_PAGE:
InvalidateRect(hWnd, NULL, TRUE);
servo_motor_page(hWnd);
UpdateWindow(hWnd);
break;
case DC_MOTOR_PAGE:
InvalidateRect(hWnd, NULL, TRUE);
dc_motor_page(hWnd);
UpdateWindow(hWnd);
break;
}
break;
case WM_CREATE:
main_menu_page(hWnd);
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
// switch (current_page) {
// case HOME_PAGE:
// main_menu_page(hWnd);
// break;
// case MOTORS_PAGE:
// motors_page(hWnd);
// break;
// case ELECTRICAL_PAGE:
// electrical_page(hWnd);
// break;
// case WEATHER_PAGE:
// weather_page(hWnd);
// break;
// case LED_CONTROL_PAGE:
// led_control_page(hWnd);
// break;
// case SERVO_MOTOR_PAGE:
// servo_motor_page(hWnd);
// break;
// case DC_MOTOR_PAGE:
// dc_motor_page(hWnd);
// break;
// }
EndPaint(hWnd, &ps);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_QUIT:
break;
default:
return DefWindowProcW(hWnd, msg, wp, lp);
}
return 0;
}
case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); // Clear the entire client area before drawing the new page RECT rect...
case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); // Clear the entire client area before drawing the new page RECT rect; GetClientRect(hWnd, &rect); FillRect(hdc, &rect, (HBRUSH)(COLOR_WINDOW + 1)); // Draw the current page switch (current_page) { case HOME_PAGE: main_menu_page(hWnd); break; case MOTORS_PAGE: motors_page(hWnd); break; case ELECTRICAL_PAGE: electrical_page(hWnd); break; case WEATHER_PAGE: weather_page(hWnd); break; case LED_CONTROL_PAGE: led_control_page(hWnd); break; case SERVO_MOTOR_PAGE: servo_motor_page(hWnd); break; case DC_MOTOR_PAGE: dc_motor_page(hWnd); break; } EndPaint(hWnd, &ps); } break;