Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

A file selection dialog and a label with the name of the selected file

15 views
Skip to first unread message

Alex

unread,
Apr 16, 2024, 4:02:45 AM4/16/24
to dislin-users
Hi!

I have the following questions about the program:

void GetFileName(int id);

int colBorderX = 30, colBorderY = 30, wgX = 150, wgY = 50, id_main;

int main()
{
  int screen_width, screen_height;
  g.getscr (&screen_width, &screen_height);
  g.swgwin (-7, 0, screen_width + 14, screen_height);
  g.swgtit ("Dislin study");
  id_main = g.wgini ("form");
  int id_basbtn  = g.wgbas (id_main, "form");
  g.swgwin (colBorderX, colBorderY, wgX, wgY);
  int id_btn  = g.wgpbut (id_basbtn, "Start");
  g.swgcbk (id_btn, GetFileName);
  g.wgfin ();
  return 0;
}

void GetFileName(int id)
{
  char* chfile = new char[255];
  chfile = g.dwgfil ("Select a file", "File", "*.cpp;*.h");
  int id_baslab = g.wgbas(id_main, "form");
  g.swgwin (colBorderX, 5*colBorderY, wgX*5, 2*wgY);
  int id_lab = g.wglab(id_baslab, chfile);
  delete chfile;
}

1. Why does the second line appear when you click the Start button again, although the location of the second line should be the same as the first line. I attached the video.
2. How do I make it possible to select a file extension separately? Which separator should be used in the third parameter of the dwgfil function?
3. Which Dislin function allows you to get the label text?

Alex
2string.mp4

Alex

unread,
Apr 16, 2024, 6:27:52 AM4/16/24
to dislin-users
I would also like to ask why the file selection dialog appears subjectively for a very long time after clicking the Start button?

Alex

unread,
Apr 16, 2024, 10:09:02 AM4/16/24
to dislin-users
I found the answer to the first question. The correct order:

  g.swgwin (colBorderX, 5*colBorderY, wgX*5, 2*wgY);
  int id_baslab = g.wgbas(id_main, "form");
then the label does not move down when you press the Start button again

Alex

unread,
Apr 18, 2024, 9:38:21 AM4/18/24
to dislin-users
Hi!

Does anyone know the answers to the second and third questions?

Alex

Reply all
Reply to author
Forward
0 new messages