Giter Club home page Giter Club logo

Comments (23)

bstaint avatar bstaint commented on June 6, 2024

我白天也折腾了下x64下,出现几处问题:

在msvc的x64下,有这句的话self.chkListBox.SetParent(self);,运行就会提示
1

点击OK后程序正常跑,listboxcustomdraw也会出现上面的错误,并且运行效果如图:
2

from rust-vcl.

ying32 avatar ying32 commented on June 6, 2024

你只要不使用自绘的样式就没问题的。

from rust-vcl.

bstaint avatar bstaint commented on June 6, 2024

我尝试了下,没问题了,感谢

from rust-vcl.

bstaint avatar bstaint commented on June 6, 2024

请问下,我试着实现例子里的listview,结果图标的位置很乱:
1

        self.lv2.SetParent(self)
            .SetAlign(TAlign::alTop)
            .SetReadOnly(true)
            .SetRowSelect(true)
            .SetViewStyle(TViewStyle::vsIcon)
            .SetLargeImages(&self.imgList)
            .SetOnClick(sid, |cls: &TMainForm, sender: usize|{
                let idx = cls.lv2.ItemIndex();
                if idx != -1 {
                    let item = cls.lv2.Selected();
                    println!("{}, {}", item.Caption(), item.SubItems().Strings(0));
                }
            })
            // 双击删除选中项
            .SetOnDblClick(sid, |cls: &TMainForm, sender: usize|{
                let idx = cls.lv2.ItemIndex();
                if  idx != -1 {
                    cls.lv2.Items().Delete(idx);
                }
            });

        self.lv2.Items().BeginUpdate();
        for i in 0..10 {
            self.lv2.Items().Add()
                .SetImageIndex(0)
                .SetCaption(&format!("{}", i))
                .SubItems().Add(&format!("值:{}", i));
        }
        self.lv2.Items().EndUpdate();

这个问题是啥原因?

还有个问题,按照例子的图片lv3应该是分组,但是代码里看跟lv1差不多,没看到具体哪里是分组的关键代码。

from rust-vcl.

ying32 avatar ying32 commented on June 6, 2024

我看了下,那个截图是原来的,这个没更新了,这个他是根据当前宽度计算的,还没有显示,有些值还没生效,加一句

lv2.SetWidth(self.form.Width())

from rust-vcl.

bstaint avatar bstaint commented on June 6, 2024

好的 感谢回复。

from rust-vcl.

ying32 avatar ying32 commented on June 6, 2024

没注意你还一个问题,分组是原来libvcl所支持的,现在liblcl不支持这个

from rust-vcl.

bstaint avatar bstaint commented on June 6, 2024

请教下TMemoryStream在rust中的使用:

        let message: [char; 5] = ['h', 'e', 'l', 'l', 'o'];
        let mut stream = TMemoryStream::new();
        stream.Write(&message as * const char as usize, 5);
        println!("{}, {:?}", stream.Position(), stream.ToString());
        stream.Free();

这个打印出来是5, "TMemoryStream"?
另外SetPostion的签名是pub fn SetPosition(&self, aValue: *mut i64) -> &Self
我看govcl里直接是int64是否有问题?

还有个小问题,关于

Application.Initialize();

这里应该如何写比较适合:

            // let sid = Application.getSId(); ???
            Application.SetOnMinimize(sid, |cls: &TApp, sender: usize|{

            })

还有有没有设置活动窗口的API。

from rust-vcl.

ying32 avatar ying32 commented on June 6, 2024
  • 1、SetPosition这个是AST没有生成正确的,明天改改。
  • 2、WriteRead方法也要修改下。
  • 3、Application.SetOnMinimize这个在主窗口里面设置就行了
impl TMainForm  {
   fn init(&self) -> Self {
        let sid = self.getSId();
        Application.SetOnMinimize(sid, Self::onAppMinimize);
        return &self;
    }

    fn onAppMinimize(&self, _sender: usize) {
        println!("AppMinimize");
    }

}
  • 4、设置活动窗口的API?哪一种?比如?

from rust-vcl.

bstaint avatar bstaint commented on June 6, 2024

哦,对 感谢,比如trayicon在mainFrom.Hide()之后mainFrom.Show()的话窗口还在其他窗口后面不是激活状态,WINAPI的话应该是SetActiveWindow

from rust-vcl.

ying32 avatar ying32 commented on June 6, 2024

Show之后调用 Application.Restore();,不过貌似有个问题,位置会变动,还得找找原因

from rust-vcl.

bstaint avatar bstaint commented on June 6, 2024

试了,感谢,建议把实例中的i8数组改成char,rust里在x86下char占4个字节,比较有代表性:

        let message: [char; 5] = ['h', 'e', 'l', 'l', 'o'];
        let mut stream = TMemoryStream::new();
        stream.Write(
            &message as * const char as usize,
            message.len() as i32 * std::mem::size_of::<char>() as i32
        );
        stream.SetPosition(0);

        let mut read_message: [char; 5] = ['\0'; 5];
        let len = stream.Read(
            &read_message as * const char as usize,
            read_message.len() as i32 * std::mem::size_of::<char>() as i32
        );

from rust-vcl.

ying32 avatar ying32 commented on June 6, 2024

那倒没必要,不过我添加了几个新的方法:

pub fn WriteByte(&self, value: i8) -> i32
pub fn ReadByte(&self) -> i8
pub fn WriteArray<T>(&self, data: &[T]) -> i32
pub fn ReadArray<T>(&self, data: &[T]) -> i32

另外将WriteRead方法弄成泛型的了

pub fn Read<T>(&self, buffer: *const T, count: i32) -> i32
pub fn Write<T>(&self, buffer: *const T, count: i32) -> i32

本来想弄个通用的,但是泛型初始值没找到怎么赋值。

from rust-vcl.

bstaint avatar bstaint commented on June 6, 2024

感谢。

from rust-vcl.

bstaint avatar bstaint commented on June 6, 2024

请教个问题,有没有可能拿到TMainForm里的字段,TApplication::MainForm取的似乎是TMainForm.form

我在实现simpleIM\IMServer的时候协程用的是async_std

impl TMainForm {

    fn build(&self) {
        // ...
        async_std::task::spawn(async {
            println!("initTCP begin");
            initTCP().await;
        });
   }
}

这里不好捕获self,在之后的initTCPnewConn就不容易操作控件,目前我的方法是

    let app : &TApplication = &Application;
    let inst = app.MainForm().FindChildControl("online").Instance();

    println!("{:?}", TLabel::As(inst).Caption());

另外ThreadSync还没有实现好像。

from rust-vcl.

ying32 avatar ying32 commented on June 6, 2024
  • 1、从Application.MainForm拿不到当前的字段。。。 你看从app的实例拿拿看。。
  • 2、ThreadSync一直没有好办法,所以暂时搁置状态。

from rust-vcl.

bstaint avatar bstaint commented on June 6, 2024

好的,谢谢回复

另外问下TApplication能转成TApp么

from rust-vcl.

ying32 avatar ying32 commented on June 6, 2024

不能吧。。。

from rust-vcl.

bstaint avatar bstaint commented on June 6, 2024

确实,现在只能用lazy_static了:

struct MyData {
    onlineClientCount: Mutex<usize>,
    clientMap: Mutex<HashMap<SocketAddr, String>>,
}

lazy_static! {
    static ref DATA: MyData = MyData::new();
    static ref APP: TApp  = TApp::new();
}

from rust-vcl.

ying32 avatar ying32 commented on June 6, 2024

Rust中写这些东西感觉限制老大了

from rust-vcl.

ying32 avatar ying32 commented on June 6, 2024

设置事件上做了些小修改,移除了getSId方法,目前直接传self,如下:

// TButton
self.btn3
	.SetParent(self)
	.SetLeft(10)
	.SetTop(self.btn2.Top() + self.btn2.Height() + 10)
	.SetCaption("MsgBox")
	.SetOnClick(self, Self::onBtn3Click);

不过不能传&self哦,因为参数是&T,传&self似乎编译器会认为是指针的指针。

from rust-vcl.

bstaint avatar bstaint commented on June 6, 2024

好的,感谢提醒 回头我试试。

from rust-vcl.

ying32 avatar ying32 commented on June 6, 2024

这个issue太长了,先关了😂

from rust-vcl.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.