标题:求助,在表单上用程序插入文本框的问题,谢谢。
只看楼主
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
得分:0 
我都不知道你到底想怎麽用

授人以渔,不授人以鱼。
2016-01-09 21:46
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
得分:0 
再測試一下
sample.zip (14.53 KB)


1.加到數據庫中並沒什麽問題,關鍵看需求,要具體。
2.照這個界面和數據分佈看,豎直方向很難超出邊界,不用原先設計的數字亦可;橫向會超,可以加個控制按鈕,左右平移觀察。現在拉伸窗體邊界是看到被裁剪部分的。

授人以渔,不授人以鱼。
2016-01-09 22:32
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
得分:0 
程序代码:
CLEAR ALL
CLEAR 

IF Application.StartMode == 0
    SET PATH TO ADDBS(Application.ActiveProject.HomeDir) + "..\MyTools" ADDITIVE 
    SET PATH TO ADDBS(Application.ActiveProject.HomeDir) + "Source" ADDITIVE 
ENDIF 
SET PROCEDURE TO "MyForm" ADDITIVE 
SET PROCEDURE TO "MyGet" ADDITIVE 
SET PROCEDURE TO "Ball" ADDITIVE 

Main()

CLEAR ALL
RETURN


PROCEDURE Main()
    LOCAL loMainForm
    loMainForm = CREATEOBJECT("_MainForm")
    WITH loMainForm
        .Caption = "Sample"
        .MinWidth = 800
        .MinHeight = 600
        .AutoCenter = .T.
        .Show
    ENDWITH 
    READ EVENTS
ENDPROC 

FUNCTION Get_Ball(tnMin, tnMax)
    RETURN INT((tnMax - tnMin + 1) * RAND() + tnMin)
ENDFUNC 

DEFINE CLASS _Input AS MyGet
    
    ADD OBJECT Label1 AS Label   WITH Caption = "隨機數範圍:"
    ADD OBJECT Text1  AS TextBox WITH Value = 50
    ADD OBJECT Label2 AS Label   WITH Caption = "運行次數:"
    ADD OBJECT Text2  AS TextBox WITH Value = 200
    ADD OBJECT Label3 AS Label   WITH Caption = "係數:"
    ADD OBJECT Text3  AS TextBox WITH Value = 25
    
    PROCEDURE Init
        WITH This
            .SetAll("Width", 100, "Label")
            .SetAll("Width", 60, "TextBox")
            .SetAll("Height", 25) 
            .SetAll("Alignment", 1, "Label")
            .SetAll("SelectOnEntry", .T., "TextBox")
        ENDWITH 
    ENDPROC 
    
ENDDEFINE


DEFINE CLASS _MainForm AS MyForm

    PROCEDURE Generate_Balls(tnRange, tnTimes, tnCoefficient)
        LOCAL lnIndex, lcName
        WITH This.oMap
            .AddProperty("Balls[" + TRANSFORM(tnTimes) + "]")
            FOR lnIndex = 1 TO tnTimes
                lcName = "Balls[" + TRANSFORM(lnIndex) + "]"
                .AddObject("&lcName", "Ball", Get_Ball(1, tnRange), tnCoefficient)
            NEXT 
            .SetAll("Visible", .T., "Ball")
            .Arrange
        ENDWITH 
    ENDPROC 
    
    ADD OBJECT oInput AS _Input WITH Top = 5, Left = 5
    
    ADD OBJECT oMap AS Container WITH BorderWidth = 0
    PROCEDURE oMap.Arrange
        LOCAL lnIndex, lnRow, lnCol
        lnRow = 0
        lnCol = 0
        FOR lnIndex = 1 TO ALEN(This.Balls, 1)
            IF (lnIndex > 1) .AND. (This.Balls[lnIndex].ForeColor != This.Balls[lnIndex-1].ForeColor)
                lnRow = 0
                lnCol = lnCol + 1
            ENDIF 
            WITH This.Balls[lnIndex]
                .Top = 5 + lnRow * (.Height + 5)
                .Left = 5 + lnCol * (.Width + 5)
            ENDWITH 
            lnRow = lnRow + 1
        NEXT 
    ENDPROC 
    PROCEDURE oMap.Clear
        WITH This
            DO WHILE .ControlCount > 0
                .RemoveObject(.Controls[.ControlCount].Name)
            ENDDO 
        ENDWITH 
    ENDPROC 

    ADD OBJECT Button AS CommandButton WITH Caption = "開始", Width = 80, Height = 25
    PROCEDURE Button.Click
        WITH This.Parent
            .oMap.Clear
            .Generate_Balls(.oInput.Text1.Value, .oInput.Text2.Value, .oInput.Text3.Value)
        ENDWITH 
    ENDPROC 
    
    PROCEDURE Arrange
        DODEFAULT()
        WITH This.Button
            .Top = This.oInput.Top
            .Left = This.Width - .Width - 5
        ENDWITH 
        WITH This.oMap
            .Top = This.oInput.Top + This.oInput.Height + 5
            .Left = 5
            .Height = This.Height - .Top - 5
            .Width = This.Width - .Left - 5
        ENDWITH 
    ENDPROC 
    
ENDDEFINE

授人以渔,不授人以鱼。
2016-01-09 23:53
a23209084
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2016-1-6
得分:0 
回复 7楼 TonyDeng
版主辛苦了加我QQ264801444或微信xuwei-7198,我们进一步沟通好吗?

[此贴子已经被作者于2016-1-10 15:44编辑过]

2016-01-10 15:17
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
得分:0 
這樣的代碼看得懂嗎?13樓是沒給全部的,祇是程序的主骨架。其餘沒給的部分,基本都在壇上公開過。

授人以渔,不授人以鱼。
2016-01-10 15:42
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
得分:0 
Ball.PRG
程序代码:
#include "FoxPro.h"

DEFINE CLASS Ball AS Label
    
    Width = 40
    Height = 20
    Alignment = 2
    BackColor = COLOR_GRAY
    
    PROCEDURE Init(tnNumber, tnCoefficient)
        WITH This
            .Caption = TRANSFORM(tnNumber)
            .ForeColor = IIF(tnNumber <= tnCoefficient, COLOR_RED, COLOR_BLUE)
        ENDWITH 
    ENDPROC 
    
ENDDEFINE

授人以渔,不授人以鱼。
2016-01-10 15:48
flyingcat2008
Rank: 2
来 自:湖南
等 级:论坛游民
帖 子:33
专家分:13
注 册:2008-7-28
得分:0 
两位版主的代码都很漂亮。
2016-01-10 15:48
a23209084
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2016-1-6
得分:0 
回复 16楼 TonyDeng
有些能看懂,有些完全看不懂版主加我QQ264801444或微信xuwei-7198,我们进一步沟通好吗?
2016-01-10 15:53
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
得分:0 
看短消息

授人以渔,不授人以鱼。
2016-01-10 17:45
厨师王德榜
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:183
帖 子:942
专家分:4724
注 册:2013-2-16
得分:0 
这是准备把下期的彩池掏空的节奏啊。
2016-01-11 11:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-460935-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.368507 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved