Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Selecting a file and directory in the file system tree

41 views
Skip to first unread message

Alex Tuchin

unread,
Mar 19, 2024, 11:24:24 AM3/19/24
to dislin-users
Hello!
Tell me, please, are there widgets in Dislin that allow you to select a file or directory from the file system tree, and not by typing in the input field? When I installed the library, a simple input field appeared in which I manually changed the drive letter. If there is such a possibility, where can I find examples with such widgets?

Helmut Michels

unread,
Mar 20, 2024, 7:37:19 AM3/20/24
to dislin-users
Hi,

the widget routine wgfil creates a text field, where you can type the name of a file, and makes an
entry in the 'File' menu, where a file selection box is displayed when the menu entry is clicked.

With best regards,

Helmut

Alex Tuchin

unread,
Mar 21, 2024, 9:08:03 AM3/21/24
to dislin-users
Hi!
Thanks for the answer! The following questions:
1. I would really like to see an example with a file menu in C++?
2. Where can I find acceptable values for the second parameters (char*) for wgbas and wglab?

среда, 20 марта 2024 г. в 14:37:19 UTC+3, mic...@dislin-software.de:
Message has been deleted
Message has been deleted

Alex

unread,
Mar 22, 2024, 11:03:55 AM3/22/24
to dislin-users
Hi!
Windows 10 64 bit, Codeblocks 32 bit.
I tried to do as Helmut advised, but it didn't work out:

  int ip_file = g.wgpop (ip, "File");
  g.swgcbk (ip_file, FileNameSelect);
  ip_l = g.wgbas (ip, "vert");
  g.wgquit (ip_l);
  g.wgfin ();
}

void FileNameSelect(int id)
{
  g.dwgfil ("Message", "D:", "*.cpp");
  return;
}

When you click on the menu item, the file selection dialog box does not load. I hope for Helmut's help. 
I also wanted to ask the following:
1. How to set the desired window dimensions in height and width, regardless of the widgets on it?
2. How to make the window be placed in the center of the screen when loading the program?
3. How to maximize the window.


With best regards,
    Alex

Helmut Michels

unread,
Mar 23, 2024, 6:54:54 AM3/23/24
to dislin-users
Hi Alex,

I suggested to use wgfil. For example:
 ----
int main ()
{
  int ip = g.wgini ("vert");
  int ip_file = g.wgfil (ip, "test", "d:\\", "*.cpp");
  g.swgcbk (ip_file, FileNameSelect);
  g.wgquit (ip);
  g.wgfin ();
  return 0;
}

void FileNameSelect(int id)
{ char s[257];
  g.gwgfil (id, s);
  std::cout << s << "\n";
}
------

The problem with your code is, that wgpop creates a popup menu, where you can
add menu entries with the routine wgapp and connect callback routines with the
menu entries. If you want to connect the popup menu directly with a callback routine,
you have to tell it Dislin with the option swgtyp ("string", "popup") before wgpop.
For example:

---
int main ()
{
  int ip = g.wgini ("vert");
  g.swgtyp ("string", "popup");

  int ip_file = g.wgpop (ip, "File");
  g.swgcbk (ip_file, FileNameSelect);
  g.wgquit (ip);
  g.wgfin ();
  return 0;
}

void FileNameSelect(int id)
{ char s[257];
  strcpy (s, "d:\\");
  g.dwgfil ("Message", s, "*.cpp");
  std::cout << s << "\n";
}
-----

It seems that the Windows file selection box has a problem with the pre-defined
file name 'd:'. It do not want pop up. So, please use 'd:\\', or something else.

If you want to have full control over the position and size of the main widget, you should
use a 'FORM' main widget, where you can define the size and position of each widget
with the routine swgwin. Otherwise, the size of the main widget is calculated from the
included child widgets. For example:

----
int main ()
{ int screen_width, screen_height;
  int width = 800, height = 600, nx, ny;
 
  g.getscr (&screen_width, &screen_height);
  g.swgwin ((screen_width - width) / 2, (screen_height - height) / 2,
            width, height);
  int ip = g.wgini ("form");
  g.wgfin ();
  return 0;
}
----

With best regards,

Helmut

Alex

unread,
Mar 23, 2024, 10:27:47 AM3/23/24
to dislin-users
Hi, Helmut!

Thanks a lot for the detailed answers with code examples! It is especially important that the author of the library answers the questions quickly and fully! I still don't know the library and its features very well, but I really want to master at least its basic features. I hope for your help in the form of answers to my questions.

With best regards, 

Alex

Alex Tuchin

unread,
Mar 24, 2024, 4:37:29 AM3/24/24
to dislin-users
Hi!
I also really like the library. 
But still, how can I maximize the widget without determining the screen size?

суббота, 23 марта 2024 г. в 17:27:47 UTC+3, alex5...@gmail.com:

Helmut Michels

unread,
Mar 25, 2024, 5:03:30 AM3/25/24
to dislin-users
Sorry, there is no such option in Dislin. I have added it to my ToDo list.

With best regards,

Helmut

Alex Tuchin

unread,
Mar 25, 2024, 10:44:42 AM3/25/24
to dislin-users
Hi, Helmut

It's okay, but dislin has many other useful features. I would just like to be able to create a maximized window.

With best regards, Alex


понедельник, 25 марта 2024 г. в 12:03:30 UTC+3, mic...@dislin-software.de:
Reply all
Reply to author
Forward
0 new messages