使用C语言编写GUI的软件,一般需要GUI相关的库,比如QT库,比如Windows上的SDK库。需要专门找这方面的资料学习。以Windows为例,写一个最简单的hello world,以下程序在vc60中编译通过,实际上只是调用了一个SDK中的MessageBox函数。
12345678
#include <tcharh>#include <windowsh>#pragma comment(linker ,"/entry:mainCRTStartup /subsystem:windows")int main(){MessageBox(0, _T("hello world\n"), _T("Test"), MB_OK);return 0;}
纯C的很少,windows32
sdk和linux的gtk是为数不多的2个库。
现代基本没有用C开发gui的,C++是更好的选择,像qt
mfc比win32好用得多。
开发效率更高的是python,tkinter
wxwidget
pyqt都很方便
function pushbuttoncallback(hObject,eventdata,handles)
[FileName,PathName]=uigetfile('dcm','select the file');
file = fullfile(PathName,FileName);
data = load(file);
handlesdata = data;
guidata(hObject,handles);
不依赖桌面环境,但是依赖运行库。你可以有Gnome的运行库同时使用KDE桌面系统。也就是说只要用户安装了依赖的文件,那么两种GUI设计出的程序都是可以运行的,只不过显示上可能有所差别,同一个程序,在GNOME下运行的显示效果可能会和在KDE下的不同。
我个人是学习的GTK,但是说实话QT目前确实在跨平台上有优势,而且我也感觉两者各有长处,因此不好说推荐你学什么。
至于你说的在Deepin Linux下编译不通过,但是在Slax上通过的程序,正如前面提到的,是库的问题,也许是你在Deepin Linux没有安装对应的开发包或者版本不符而Slax上正确安装的原因
你好!
你先用GUI编辑第二个界面,保存命名如wenjian,在第一个按钮的回调函数中写如下语句:
h=gcf;
wenjian;
close(h);
然后保存,运行这个按钮界面,点击按钮就可以出现“wenjian”
这个界面了。
如有疑问,请追问。
import javaxswing;
import javaxswingtext;
import javaawt;
import javaawtevent;
/
@author Hardneedl
/
final class ButtonDemo extends JFrame {
public String getTitle() {return "ButtonDemo";}
static private final Dimension size = new Dimension(600,400);
public Dimension getPreferredSize() {return size;}
public Dimension getMaximumSize() {return size;}
public Dimension getMinimumSize() {return size;}
public Dimension getSize(){return size;}
private class ButtonAction extends AbstractAction{
private JTextComponent t;
private String n;
private ButtonAction(String name,JTextComponent t) {
super(name);
n=name;
thist=t;
}
public void actionPerformed(ActionEvent e) {
tsetText(n);
}
}
private JButton b0,b1;
private JTextField t;
ButtonDemo() throws HeadlessException {
init();
attachListeners();
doLay();
}
private void init(){
t=new JTextField(20);
b0=new JButton(new ButtonAction("YES",t));
b1=new JButton(new ButtonAction("NO",t));
}
private void attachListeners(){
setDefaultCloseOperation(JFrameEXIT_ON_CLOSE);
}
private void doLay(){
Container container = getContentPane();
JPanel p = new JPanel();
padd(b0);
padd(b1);
containeradd(p,BorderLayoutNORTH);
containeradd(t,BorderLayoutSOUTH);
pack();
setVisible(true);
}
public static void main(Stringargs) {
SystemsetProperty("swingdefaultlaf","comsunjavaswingplafwindowsWindowsLookAndFeel");
SwingUtilitiesinvokeLater(
new Runnable(){
public void run() {
new ButtonDemo();
}
}
);
}
}
以上就是关于如何写个GUI的windows程序全部的内容,包括:如何写个GUI的windows程序、C语言如何开发桌面GUI应用程序、GUI中点击一个按钮d出一个文件打开对话框的程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)