China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-21 11:32
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » The Terminator of DOS Interface Development View 94,124 Replies 290
Floor 256 Posted 2008-04-12 15:14 ·  中国 广东 深圳 宝安区 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
Originally posted by fgckfl at 2008-4-4 11:26:
Encapsulated new table and list controls, how to draw a blinking cursor?


(1) In the Swapping function, make a time mark, assuming it's 1 second

if (abs(current time - time mark) >= 1)
{
(1) Assume that if the blinking cursor is already displayed, hide it; otherwise, display the blinking cursor
(2) Update the time mark to the current time, that is, time mark = current time
}

(2) Since the Swapping function is called all the time, try not to have "new", "delete" and other C language statements in the function, because frequent allocation and deletion of memory is easy to cause memory fragmentation, thus causing the program to crash.

(3)In the final program's Release version, after allocating memory, try not to verify the success of memory allocation,

CEdit* pEdit1 = new CEdit;
if (pEdit1 == NULL)
{
::AfxMessageBox("Memory allocation", "Memory allocation failed!", MB_OK);
}


The above code has two disadvantages:
<1> The code segment is increased. Since DOS programs are limited by 640K memory, the amount of code should be reduced as much as possible! This is a note when programming under DOS!
<2> The data segment is increased. Since the C language large model has only one 64K data segment, try to handle error messages with error handling functions!

[ Last edited by firstsail on 2008-4-12 at 06:28 PM ]
Floor 257 Posted 2008-04-16 17:33 ·  中国 广东 深圳 电信
初级用户
Credits 28
Posts 13
Joined 2008-02-18 12:33
18-year member
UID 110885
Gender Male
Status Offline
Just came back after being on a business trip for about a month. Brother Guo, you're welcome! :-)

Regarding the issue of DOS 640K conventional memory, has Brother Guo ever considered compiling code in overlay mode?
Floor 258 Posted 2008-05-05 16:22 ·  中国 江苏 苏州 电信
初级用户
Credits 28
Posts 13
Joined 2008-02-18 12:33
18-year member
UID 110885
Gender Male
Status Offline
Such a good thing, how can it sink?
Post a thread to bring it up! ^_^

Another thing: Brother Guo, take a look if there is a small bug in CComboBox: when there is only one item selectable in CComboBox, then pulling the drop-down scroll bar has an exception. Please check it.
Floor 259 Posted 2008-05-06 15:08 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
1: The bug is found, mainly caused by the CScrollBar::SetRange() function.

void CScrollBar::SetRange(DWORD dwMin,DWORD dwMax)
{
if (dwMax > dwMin)
{
m_dwMax=dwMax;
m_dwMin=dwMin;

}
}

When there is 1 item, then dwMin = 0, dwMax = 0. At this time, the above code causes the "value" not to be updated.

Now the corrected code is as follows:
void CScrollBar::SetRange(DWORD dwMin,DWORD dwMax)
{
if (dwMax >= dwMin)
{
m_dwMax=dwMax;
m_dwMin=dwMin;

if (m_dwLocation < m_dwMin)
{
m_dwLocation = m_dwMin;
}
else if (m_dwLocation > m_dwMax)
{
m_dwLocation = m_dwMax;
}
}
}
Floor 260 Posted 2008-05-06 19:13 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
Since the C language large model only has one 64K data segment, when users need global variables with large amounts of data, it is recommended to set the data type of the variable to a "far" type data variable.

There is a global variable array that occupies 16K bytes. If configured as

WORD wsGobalArray[4][2048];

At this time, a 64K segment overflow may occur. Therefore, the correct configuration should be as follows:

WORD far wsGobalArray[4][2048];

Large arrays are generally used for "AD sampling"!
Floor 261 Posted 2008-05-08 12:05 ·  中国 广东 深圳 电信
初级用户
Credits 28
Posts 13
Joined 2008-02-18 12:33
18-year member
UID 110885
Gender Male
Status Offline
Brother Guo: The CComboBox has been tested and is working properly.

Under the Large mode of the BC compilation environment, it seems that what I understand is that the compiler automatically makes all functions and pointers far. I don't know if the understanding is correct.

The instructions under BC are as follows:
"Use Large model for very large applications only.
Far pointers are used for both codes and data, giving both a 1MB range. All function and data pointers are far by default."
Floor 262 Posted 2008-05-08 12:37 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
(1)For pointers and functions, in the large model, all are of far type.

(2)For global variables, the variable without far type is in the "DATA" data segment, and the far - type data type is in the "FAR_DATA" data segment.

Suppose there is an abc.Cpp file as follows:

#include <Symbol.h>

WORD wAfxData1;
WORD far wAfxData2;


void Abcd()
{
wAfxData1 = 0;
wAfxData2 = 0;
}

When the above abc.Cpp file is compiled in the large model, note to select the menu ->->Generate Assembler Source. At this time, the "abc.asm" assembly file will be left on the disk. Open it with notepad or edit program and you can see the "DATA" and "FAR_DATA" data segments.

<1> When accessing the "DATA" data segment, the CPU automatically uses the DS register as the segment register, so the access speed is relatively fast.

<2> When accessing the "FAR_DATA" data segment, the program loads the segment address of the FAR_DATA segment into the ES register, and then accesses the variable correctly, so the access speed is slow.

The assembly language corresponding to the above Abcd function is as follows:

; void Abcd()
;
assume cs:ABC_TEXT
@Abcd$qv proc far
push bp
mov bp,sp
;
; {
; wAfxData1 = 0;
;
mov word ptr DGROUP:_wAfxData1,0
;
; wAfxData2 = 0;
;
mov ax,seg _wAfxData2
mov es,ax
mov word ptr es:_wAfxData2,0
;
; }
;
pop bp
ret
@Abcd$qv endp

[ Last edited by firstsail on 2008-5-8 at 12:54 PM ]
Floor 263 Posted 2008-07-10 13:37 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
Due to the old version of WinSail, when the "F3" function key is pressed in the window, the current window is stored with a fixed file name ------ the "A.Bmp" file, which is often inconvenient in industrial sites. Now it is changed to:

When the "F3" function key is pressed in the window, an input box will pop up for the user to enter the file name, and then the picture will be stored with the entered file name.

Download address: "http://www.firstsail.com.cn/software.html"
Floor 264 Posted 2008-07-16 11:59 ·  中国 广东 广州 天河区 电信
初级用户
Credits 161
Posts 15
Joined 2003-11-12 00:00
22-year member
UID 12742
Gender Male
Status Offline
For the industrial PC104 boards, many applications need to use hard terminals, such as IRQ10, etc., and perform calculations, IO operations, etc. in the interrupt program. Can it be supported with the owner's system?
Floor 265 Posted 2008-07-17 12:00 ·  中国 广东 深圳 电信
初级用户
Credits 28
Posts 13
Joined 2008-02-18 12:33
18-year member
UID 110885
Gender Male
Status Offline
Mr. Guo, there is a phenomenon that occurs during the trial of your winsail program: the PS2 mouse pointer sometimes flies around and drops occasionally in a vibrating environment. It is initially judged to be a mouse communication error caused by interference.

Does your mouse driver use the standard driver loading and then call INT33h to drive the mouse?

Is there a possibility that I can control the mouse call by myself? For example, after finding the乱飞 situation caused by data misalignment, re-call the mouse initialization and other operations.
Floor 266 Posted 2008-09-19 18:57 ·  中国 广东 深圳 宝安区 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
1) WinSail already supports 64K colors, which is 16-bit color.

If it is 640x680x16-bit color, the Config.Sys settings are as follows:
Device = 11
Mode = 111

If it is 800x600x16-bit color, the Config.Sys settings are as follows:
Device = 11
Mode = 114

If it is 1024x768x16-bit color, the Config.Sys settings are as follows:
Device = 11
Mode = 117


(2) After downloading and extracting, there is a file Sail3000\bmp3\Color1.Bmp for testing, which is a 24-bit true color picture


(3) The test program can use the following code segment
void Demo_DisplayBmp()
{

char bufFile;

// Call the open file dialog function to select the "BMP" file
while (::AfxOpenFileDialog(TRUE, bufFile, NULL))
{

// Save the mouse state
int nMouse = ::GetMouse();
// Before drawing, the mouse must be closed
::CloseMouse();

// Clear the viewport
::ClearViewPort();

// Display the picture
::DisplayBmpFile(0, 0, bufFile);

// Restore the mouse state
::SetMouse(nMouse);
}

return;
}




Download address of WinSail: http://www.firstsail.com.cn/Software.html

[ Last edited by firstsail on 2008-10-5 at 17:51 ]
Floor 267 Posted 2008-10-05 17:13 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
WinSail has added the animation control CAnimalCtrl, which can currently only play GIF files.



(1) The class definition is in the header file "MyFrame.h".
(2) The document name is: "Interface Control Class _CAnimalCtrl Animation Control Detailed Design.doc".

(3) Applying this control is very simple, generally only three lines of code are needed

// Allocate instance
CAnimalCtrl* pAnimalCtrl1 = new CAnimalCtrl(pDialog);
// Create control
pAnimalCtrl1->CreateObject(100, 100, 50, 50, NULL);
// Load GIF file
pAnimalCtrl1->LoadFile("Bmp\\Earth3.Gif");


After downloading WinSail and extracting it, run the Sai2000 program in sail3000. You can see a rotating Earth in the upper right corner of the desktop.
It is recommended to adjust WinSail to 256 colors or "16 bits = 64K colors", at this time the color of the animation control is the most realistic.


Note: After using the animation control CAnimalCtrl, the Exe file increases by about 7K of code.

7 Example
#include <bios.h>
#include <Stdio.h>
#include <Stdlib.h>
#include <conio.h>
#include <dos.h>
#include <String.h>
#include <math.h>

#include <Symbol.H>
#include <MyFrame.h>
#include <gif.h>
#include <Lzw.h>

int far TransrateKey(CObject *)

{

return(0);

}

unsigned _stklen = 60u * 1024u;

// A callback function corresponding to a button in the animation control demonstration function
void far ClickButton1_DemoAnimalCtrl(CObject *pObj)
{
// Get the pointer to the parent window corresponding to the animation control
CDialog* pDialog = (CDialog *)pObj->GetParent();
// Get the pointer to the animation control
CAnimalCtrl* pAnimalCtrl = (CAnimalCtrl *)
pDialog->ObjectFromID(ANIMALBASE + 1 - 1);

// Select a new GIF file
char bufFile;
if (!AfxOpenFileDialog(TRUE, bufFile, NULL))
{
return;
}

// Load the new GIF file
pAnimalCtrl->LoadFile(bufFile);
// Since the size of each animation is different, the window must be refreshed again
pDialog->ShowWindow();

return;
}

// Animation control demonstration function
void far Demo_AnimalCtrl()
{
// Allocate dialog instance
CDialog* pDialog = new CDialog;
// Create dialog
pDialog->CreateWindow(0,0,640,480,"Animation Control Demonstration Program");
// Center the window
pDialog->Center();

// Allocate instance of animation control
CAnimalCtrl* pAnimalCtrl = new CAnimalCtrl(pDialog);
// Create animation control, the meaning of the width and height of this control is not significant.
pAnimalCtrl->CreateObject(5,30,40,100, NULL);
// Load animation GIF file
pAnimalCtrl->LoadFile("Bmp\\Earth3.gif");
// Set the ID number of the animation control
pAnimalCtrl->SetID(ANIMALBASE + 1 - 1);

// Allocate button instance
CButton* pButton1 = new CButton(pDialog);
// Create button
pButton1->CreateObject(500, 50, 80, 24, "Load");
// Set the callback function corresponding to the button
pButton1->SetFc(ClickButton1_DemoAnimalCtrl);

// Show dialog
pDialog->ShowWindow();
// Enter the message loop of the dialog
pDialog->DoModal();

// Delete dialog instance
delete pDialog;
// Function return
return;
}

int main(int argc, char** argv)
{
// Initialize WinSail system
if (!::InitSystem(argc, argv))
{
::CloseSystem();
return(0);
}

// Call animation demonstration program
::Demo_AnimalCtrl();

// Exit WinSail system
::CloseSystem();
return(1);
}

Download address of WinSail: http://www.firstsail.com.cn/Software.html

[ Last edited by firstsail on 2008-10-5 at 17:53 ]
Floor 268 Posted 2008-10-05 17:31 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
To increase the animation controls, WinSail has added a system global timer, currently tentatively set to a maximum of 20.

(1) Function WinSail_SetTimer();
Original prototype: int WinSail_SetTimer(DWORD dwParam, WORD wTime, void far(*pFc)(DWORD dwParam), DWORD dwWindow);
Function: Establish a system timer
Entry parameters: DWORD dwParam ---------- Entry pointer of the timer callback function
WORD wTime------------- Timer time, in units of 55mS (i.e., 1/18.2S)
void far(*pFc)(DWORD)--- Timer callback function
DWORD dwWindow---------- Belonging window pointer, NULL if not belonging
Exit parameters: None
Return value: Returns timer handle 0, 1, 2,.... if successful; returns "-1" if failed.

(2) Function WinSail_KillTimer()
Original prototype: void WinSail_KillTimer(int nTimer);
Function: Delete the specified timer
Entry parameters: int nTimer ------------- Timer handle
Exit parameters: None
Return value: None

Note: If a timer with a belonging window is established, this timer must be destroyed before the window is destroyed!

Download address of WinSail: http://www.firstsail.com.cn/Software.html

[ Last edited by firstsail on 2008-10-5 at 17:55 ]
Floor 269 Posted 2008-11-02 12:40 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
WinSail supports the display of JPG files, and the system must be configured to have more than 64K colors.



device=11
mode = 117

;mode=111 is 640*480*64K colors
;mode=114 is 800*600*64K colors
;mode=117 is 1024*768*64K colors


Currently, decompressing and displaying JPG files with the resolution of 1024*768 and Y:Cb:Cr = 1:1:1 takes about 2 seconds, which is not very satisfactory. Currently, the code is being optimized!




Floor 270 Posted 2008-11-20 11:15 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
Originally posted by dama_01 at 2008-7-16 11:59:
For industrial PC104 boards, many applications need to use hard terminals, such as IRQ10, etc., and perform calculations, IO operations, etc. in the interrupt program.
Can the system you mentioned support this?


WinSail is a fully BC31-compatible embedded development system, especially suitable for PC104 applications in power and electronic systems. The problem you mentioned is fully supported.

[ Last edited by firstsail on 2008-11-20 at 11:21 ]
Forum Jump: