So I have myself a project with two files in it, AT.c and main.c (I use DEV-C++). AT.c contains all the calculation stuff I need, uses command line for I/O and works relatively fine by itself. However, since I need a GUI for the program, I also got the main.c file, which basically creates a window with textboxes for me to put the numbers in.
Anyway, now I'm kinda stuck because I have no idea how to make AT.c read values from those textboxes instead of using the scanf method. I suppose I should probably make some declarations or links between the two codes, but I haven't found anything that could help yet.
The code is main.c is the starting one you get when creating a new windows application project in Dev-C++. I only altered the LRESULTCALLBACK part.
#define ID_BUTTON 1
#define ID_TEXTBOX 2
static HWND hwndA;
static HWND hwndB;
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_CREATE:{
CreateWindow(TEXT("Button"), TEXT("Generate"),
WS_CHILD | WS_VISIBLE,
10, 160, 80, 20,
hwnd, (HMENU) ID_BUTTON, NULL, NULL
);
hwndA = CreateWindow(TEXT("EDIT"), TEXT(""),
WS_VISIBLE | WS_CHILD | WS_BORDER,
190, 130, 70, 15,
hwnd, (HMENU) ID_TEXTBOX, NULL, NULL
);
hwndB = CreateWindow(TEXT("EDIT"), TEXT(""),
WS_VISIBLE | WS_CHILD | WS_BORDER,
260, 130, 70, 15,
hwnd, (HMENU) ID_TEXTBOX, NULL, NULL
);
break;
}
case WM_COMMAND:{
if (LOWORD(wParam) == ID_BUTTON) {
char wot[256];
GetWindowText(hwndA, wot, 4);
SetWindowText(hwndB, wot);
}
}
break;
}
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
The AT.c is just big, yet very simple calculating program. Like
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int a, b, c;
main(){
scanf("%d", &a);
scanf("%d", &b);
printf("\n%d", a+b);
system("pause");
}
just with bunch of ifs and loops.
Aucun commentaire:
Enregistrer un commentaire