Guidance
指路人
g.yi.org
software / RapidQ / System / Win32 / Rapid-Q++ / test.cpp

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
// Useless test program, just trying to fit everything I can in here...

#include <windows.h>
#include <iostream.h>
#include "rapidqw32.h"

// Initialize Rapid-Q, our CALLBACK procedure is named WindowProcedure
RQ_INITIALIZE(WindowProcedure);

// Global components
RQForm form(application, WindowProcedure);
RQMainMenu mainMenu;
RQMenuItem menuItem1("&File");
RQMenuItem menuItem2("&Open");
RQMenuItem menuItem3("-");
RQMenuItem menuItem4("E&xit");
RQMenuItem menuItem5("1. Item");
RQStatusBar statusBar;
RQComboBox comboBox;
RQListBox listBox;
RQEdit edit1;
RQButton button1;
RQButton button2;
RQLabel label1;
String str("yeah");


//-------------------------- PROCEDURES -----------------------------//

void buttonClick(RQButton &sender)
{
    comboBox.setStyle(csDropDownList);
    comboBox.setSorted(TRUE);
    listBox.setSorted(TRUE);
    RQ_PRINT(String("Button 1 clicked"));
    RQ_PRINTLN;
    RQ_PRINT(edit1.getSelStart());
    RQ_PRINTLN;
    RQ_SHOWMESSAGE(String("weeeee").toString());
    str = String("what ever!") + "hello world!";
    cout << str << endl;
    cout << (String("test") == String("test")) << endl;
    cout << String("test") << endl;
    cout << RQ_LEN(str) << endl;
    edit1.setSelStart(1);
    edit1.setSelLength(2);
}

void menuItemClick(RQMenuItem &sender)
{
    cout << "Menu item click " << sender.tag << endl;
    form.close();
}

void comboBoxChange(RQComboBox &sender)
{
    cout << "Combobox change " << sender.getItemIndex() << endl;
}

void comboBoxDrawItem(int index, int state, RECT rect, RQComboBox &sender)
{
    cout << "Index " << sender.getItem(index) << " state " << state << endl;
    sender.canvas.line(rect.left, rect.top, rect.right, rect.bottom, 0x0000ff);
}

void buttonMouseMove(int x, int y, int shifts, RQButton &sender)
{
    cout << "x = " << x << ", y = " << y << endl;
}

void editKeyPress(byte ch, RQEdit &sender)
{
    cout << "Edit key press " << ch << endl;
}


//    RQBitmap bitmap1;

void formPaint(RQForm &sender)
{
    sender.canvas.line(0, 100, 0, 0, 0x0000ff);
    sender.canvas.line(0, 0, 100, 0, 0x0000ff);
    sender.canvas.line(100, 0, 100, 100, 0x0000ff);
    sender.canvas.line(0, 100, 100, 100, 0x0000ff);
    sender.canvas.paint(10, 10, 0xff0000, 0x0000ff);
    //sender.canvas.roundRect(65,65,10,10,10,10,0);
    sender.font.setFontName("Arial");
    sender.canvas.textOut(50, 50, "Argh!", 0x00ff00, -1);
    //sender.font.setFontName("MS Sans Serif");
    //sender.font.setFontSize(9);
    sender.canvas.textOut(0, 0, "Argh 2!", 0xff00ff, 0x00ff00);
    sender.canvas.rectangle(15,15,10,10,0);
    //sender.canvas.draw(50,50,bitmap1);
}


//-------------------------- MAIN PROGRAM ---------------------------//

BEGIN_GUI
    //button1.setVisible(FALSE);
    form.center();
    button1.onMouseMove = buttonMouseMove;
    //button2.setEnabled(FALSE);
    edit1.setMaxLength(5);
    edit1.onKeyPress = editKeyPress;
    edit1.setTop(180);
    RQEdit edit2("wow!");
    edit2.setReadOnly(TRUE);

    //bitmap1.canvas.roundRect(60,60,80,80,10,10,0x00ffff);

    menuItem2.setEnabled(FALSE);
    menuItem4.onClick = menuItemClick;
    mainMenu.setParent(form);
    menuItem1.setCaption("&Test");
    mainMenu.addMenu(menuItem1);
    menuItem1.addMenu(menuItem2);
    menuItem1.addMenu(menuItem3);
    menuItem1.addMenu(menuItem4);
    menuItem4.addMenu(menuItem5);
    menuItem2.setChecked(TRUE);
    //comboBox.setStyle(csOwnerDrawFixed);
    //comboBox.onDrawItem = comboBoxDrawItem;
    comboBox.setParent(form);
    comboBox.setTop(100);
    comboBox.setItemHeight(40);
    comboBox.onChange = comboBoxChange;
    comboBox.addItem("1. Apples");
    comboBox.addItem("2. Orange");
    comboBox.addItem("3. Peach");
    comboBox.addItem("4. Grapes");
    comboBox.addItem("5. Grapes");
    comboBox.addItem("6. Grapes");
    comboBox.addItem("7. Grapes");
    comboBox.addItem("8. Grapes");
    comboBox.addItem("9. Grapes");
    comboBox.addItem("10. Grapes");
    comboBox.addItem("11. Grapes");
    comboBox.addItem("12. Grapes");
    comboBox.insertItem(1, "10. Watermelon");
    comboBox.setItem(0, "to");
    comboBox.setItemIndex(1);
    listBox.setParent(form);
    listBox.setLeft(200);
    listBox.setTop(70);
    listBox.addItem("1. school");
    listBox.addItem("0. knapsack");
    listBox.addItem("2. knapsack");
    listBox.addItem("3. knapsack");
    listBox.addItem("4. knapsack");
    listBox.addItem("9. knapsack");
    listBox.addItem("7. knapsack");
    listBox.addItem("4. knapsack");
    listBox.addItem("05 knapsack");
    listBox.addItem("34 knapsack");
    listBox.addItem("0. knapsack");
    listBox.addItem("43 knapsack");
    listBox.addItem("05 knapsack");
    listBox.font.setFontName("Courier New");
    form.font.setFontName("Arial");
    form.font.setFontSize(12);
    form.onPaint = formPaint;
    button1.onClick = buttonClick;
    button1.setParent(form);
    button1.setCaption("My Button");
    button1.setTop(30);
    button1.setLeft(50);
    button1.setWidth(60);
    button1.onClick = buttonClick;
    button1.font.setFontName("Courier");
    //button1.setAlign(alLeft);
    button2.setLeft(100);
    button2.setParent(form);
    button2.setCaption("Button 2");
    button2.setTop(50);
    edit1.setParent(form);
    edit2.setLeft(170);
    edit2.setParent(form);
    statusBar.setParent(form);
    //statusBar.setSimpleText("hello world!");
    statusBar.addPanel("up");
    statusBar.addPanel("down");
    statusBar.setPanelWidth(0, 110);
    statusBar.setPanelCaption(0, "test");
    label1.setParent(form);
    label1.setCaption("hello world!");

    form.showModal();
END_GUI
// END OF PROGRAM
掌柜推荐
 
 
¥477.00 ·
 
 
¥918.00 ·
 
 
¥370.00 ·
 
 
¥271.00 ·
 
 
¥995.00 ·
 
 
¥1,580.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-08-20 12:34:45