Hello,
First let me say I completely new to implementing a GUI. I do have a
learning curve ahead of me.
However, I am attempting to implement a GUI as part of a DLL that is
accessed by another application. The DLL provides access to a radio
transceiver via an USB connection.
This is on a Windows 10 system.
Background:
HDSDR (host application) -> DLL -> (radio transceiver (USB).
There is a call within the DLL that requests a GUI be presented to the
user. That GUI will provide access to the transceiver so that certain
control parameters may be modified.
Please see the IUP code below. It appears that when IupClose is
called, IUP is closing the entire program and shutting down the DLL.
This in turn stops the host application. If I simply click on the "X" to
close the GUI window, things are fine. The GUI closes and the DLL
remains running. But if I click on the "close" button, the DLL stops.
Regards,
Ron
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iup.h>
#include "extern.h"
Ihandle *text, *dlg;
static char oput[100];
// Textbox key pressed callback
static int k_any(Ihandle *self, int c)
{
char *lpOput = &oput[0];
lpOput = IupGetAttribute(text, "VALUE"); // retrieve the
whole string
double MHz = 0;
// Treat a CR as the "do it"
if (c == K_CR)
{
double dval = strtod(lpOput, NULL);
int val = (int)dval; // cast double
value to an int
if (val == 0) // if zero, send
that as valid. (default reset)
{
MessageBoxA(NULL, "Value is blank or zero, assuming zero.
(reset to default)", "Multus Calibration", MB_OK);
//TODO: Write zero out
return IUP_CLOSE;
}
if ((val < -255) || (val > 255))
{
MessageBoxA(NULL, "Value must be in the range of -255 to
255.", "Multus Calibration", MB_OK);
return IUP_DEFAULT;
}
// TODO: Write value out
MHz = (double)val;
Multus_Set_Calibration(MHz);
return IUP_CLOSE; // close window and get out
}
return IUP_DEFAULT;
}
// OK button callback
int ok_cb(void)
{
int ret = k_any(text, K_CR); // send the textbox callback a
CR if the button is clicked
if (ret == IUP_CLOSE)
{
return IUP_CLOSE;
}
return IUP_DEFAULT;
}
// Textbox "ACTION" callback (unused)
static int action(Ihandle *self, int c, char *after)
{
return c;
}
int gui(void)
{
Ihandle *ok_bt;
int argc;
char **argv;
IupOpen(&argc, &argv);
//memset(password, 0, 100);
text = IupText(NULL);
IupSetAttribute(text, "SIZE", "50x");
IupSetCallback(text, "ACTION", (Icallback)action);
IupSetCallback(text, "K_ANY", (Icallback)k_any);
// OK button
ok_bt = IupButton(" OK ", 0);
IupSetCallback(ok_bt, "ACTION", (Icallback)ok_cb);
IupSetAttribute(ok_bt, "POSITION", "20,20");
// Dialog (window)
dlg = IupDialog(IupVbox(text, ok_bt, NULL));
IupSetAttributeHandle(dlg, "DEFAULTESC", ok_bt);
IupSetAttribute(dlg, "TITLE", "Calibration Offset (-255 to 255)");
IupSetAttribute(dlg, "BORDER", "NO");
IupSetAttribute(dlg, "RESIZE", "NO");
IupSetAttribute(dlg, "MAXBOX", "NO");
IupSetAttribute(dlg, "MINBOX", "NO");
IupSetAttribute(dlg, "MINBOX", "NO");
IupSetAttribute(dlg, "MARGIN", "100x50");
IupSetAttribute(dlg, "GAP", "10");
IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
IupMainLoop(); // this blocks the thread
returning
//for (int j = 0; j < 1000; j++)
//{
// IupLoopStep();
// Sleep(20);
//}
//IupExitLoop();
IupClose();
return 500;
}
Code snippet from main DLL:
void __stdcall ShowGUI(void)
{
int count = 0;
char test[10] = { 0 };
int status = 0;
_cprintf("[%d] ShowGUI Called, calling gui() \n",line_number++);
status = gui();
_cprintf("[%d] ShowGUI Finished, gui return status %d \n",
line_number++,status);
return;
--
73,
Ron / W4MMP
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users