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:30
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » The Terminator of DOS Interface Development View 94,123 Replies 290
Floor 226 Posted 2008-02-27 14:42 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
Updated the file open/save dialog box, with support for bmp\key05.ico files, which can be found in sail3000\bmp.



Download address "http://www.firstsail.com.cn/software.html"

[ Last edited by firstsail on 2008-2-27 at 02:46 PM ]
Floor 227 Posted 2008-03-01 11:58 ·  中国 北京 联通
初级用户
Credits 46
Posts 22
Joined 2006-11-13 10:14
19-year member
UID 70433
Gender Male
Status Offline
A small program I made. It's much more convenient to develop DOS programs with winsail. It's very strange. This program can actually communicate on the C: drive of XP. I used direct port operation. Doesn't XP work in protected mode? Could you, Firstsail, explain it?
Floor 228 Posted 2008-03-01 12:13 ·  中国 北京 中移铁通
初级用户
Credits 46
Posts 22
Joined 2006-11-13 10:14
19-year member
UID 70433
Gender Male
Status Offline
1. In the function `void far DisplayAttribSetting()` in the file "setsys.cpp", the subroutine `::AddKeyboardString("SetSys 觞\xd");` is called to display "SetSys 觞" on the screen. How to block it?
Floor 229 Posted 2008-03-01 12:14 ·  中国 北京 中移铁通
初级用户
Credits 46
Posts 22
Joined 2006-11-13 10:14
19-year member
UID 70433
Gender Male
Status Offline
2. In the "demoser.cpp" file, the function `void far OnTime_DemoCUartDialog(CObject* pCurObj)` was originally prepared as a timer callback function. However, it seemed that the program was too large and the screen was always black. Later, `void OnTime_DemoCUartDialog1(CObject* pCurObj)` was used as the timer callback function, and then `void far OnTime_DemoCUartDialog(CObject* pCurObj)` was called to solve the above problem. Is there a limit on the size of DOS interrupt functions? Because now I can't buy books on DOS programming, and I don't understand many underlying DOS things.
Floor 230 Posted 2008-03-01 12:14 ·  中国 北京 中移铁通
初级用户
Credits 46
Posts 22
Joined 2006-11-13 10:14
19-year member
UID 70433
Gender Male
Status Offline
3. In the file "demoser.cpp", in the function void far OnTime_DemoCUartDialog(CObject* pCurObj), an interesting phenomenon is found in the CMultiEdit edit box.

Buf[] is the string received by the serial port, show_buf[] is the formatted string to be displayed, and pEdit1 is a CMultiEdit* pointer;
Adopt the following operation 1:
strcat(show_buf, buf);
pEdit1->SetWindowText(show_buf);
pEdit1->Show();
It will automatically wrap lines in the displayed content

And adopt the following operation 2:
strcat(show_buf, "\n");
strcat(show_buf, buf);
pEdit1->SetWindowText(show_buf);
pEdit1->Show();
It will wrap 2 lines in the displayed content

For example: newly received buf[] = "abc1", original displayed content show_buf[] = "123";
Adopt operation 1: the display is:
abc1
123
Adopt operation 2: the display is
abc1

123

And adopt operation 3:
pEdit1->SetLineText(current line number, buf);
pEdit1->Show(); no response
Floor 231 Posted 2008-03-01 12:15 ·  中国 北京 中移铁通
初级用户
Credits 46
Posts 22
Joined 2006-11-13 10:14
19-year member
UID 70433
Gender Male
Status Offline
Uploading the program is too slow!!
Floor 232 Posted 2008-03-01 17:40 ·  中国 广东 深圳 宝安区 电信
高级用户
★★
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-3-1 12:13:
1. In the "setsys.cpp" file, the function void far DisplayAttribSetting() calls the subroutine ::AddKeyboardString("SetSys 觞\xd"), which will display "SetSys 觞" on the screen. How to block it?


(1) If running in pure DOS or Win9x, since the CPU runs at a fast speed, the human eye cannot perceive it.
(2) If running in Win2000/WinXP, due to the compatibility issue of the command line interpreter, it is recommended to add the "newline" flag to the string. That is, ::AddKeyboardString("SetSys 觞\xd\xa");

2. In the "demoser.cpp" file, the function void far OnTime_DemoCUartDialog(CObject* pCurObj) was originally prepared as a timer callback function. However, it seems that the program is too large and the screen is always black. Later, using void OnTime_DemoCUartDialog1(CObject* pCurObj) as the timer callback function and then calling void far OnTime_DemoCUartDialog(CObject* pCurObj) solves the above problem. Is there a limit on the size of DOS small interrupt functions? Because now I can't buy DOS programming books, and many underlying DOS things are not clear.


This may be an error in your code. If possible, paste the code and take a look. Note that the function parameter CObject* pCurObj at this time is the window pointer.
If the window is CWindows, generally CWindow* pWindow = (CWindow *)pCurObj;
If the window is CDialog, generally CDialog* pDialog = (CDialog *)pCurObj;

[ Last edited by firstsail on 2008-3-1 at 05:44 PM ]
Floor 233 Posted 2008-03-01 17:50 ·  中国 广东 深圳 宝安区 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
void CMultiEdit::SetWindowText(const char* pStr)
{


char buf;
int nLength = _fstrlen(pStr);


this->m_XmsMemoryData.InitListing(256);

int nPoint = 0;
for (int i = 0; i <= nLength; i++)
{
char ch = pStr;
if (ch == '\xd')
{
continue;
}
if (ch != '\xa' && ch != '\x0')
{
buf = ch;
buf = '\x0';
if (nPoint < EDIT_BUFFER_SIZE - 1)
{
continue;
}
}

nPoint = this->ModifyEditBuffer(buf, EDIT_BUFFER_SIZE);

DWORD dwLoc = this->m_XmsMemoryData.New(nPoint + 1, FALSE);
if (dwLoc == NULL)
{
continue;
}
this->m_XmsMemoryData.SetText(dwLoc, buf, nPoint + 1);


nPoint = 0;
*buf = '\0';
}
}

[ Last edited by firstsail on 2008-3-1 at 05:58 PM ]
Floor 234 Posted 2008-03-05 14:32 ·  中国 陕西 西安 电信
新手上路
Credits 2
Posts 1
Joined 2008-03-05 14:12
18-year member
UID 112089
Gender Male
Status Offline
The examples in Sail3000 have been compiled and run successfully under BC 3.1, but I can't step in or set breakpoints. Why is that?
Floor 235 Posted 2008-03-05 15:59 ·  中国 广东 深圳 电信
初级用户
Credits 28
Posts 13
Joined 2008-02-18 12:33
18-year member
UID 110885
Gender Male
Status Offline
Brother Guo, the new program has been downloaded and tested. The Cmenu menu is already okay. Thanks! :-)

Besides Alt+F, is there a way to directly open the corresponding menu item using a hotkey? For example, F1 opens the first top-level menu "File", F2 opens the second top-level menu "Edit", F3 opens the third top-level menu "Window" and similar operations? In industrial environments, sometimes the standard 101/102 keyboard is not used; it's too large. At this time, simulating an operation keyboard will be considered, only simulating some useful keys. Such composite keys like "Alt+F" are relatively difficult to implement.

Regarding the "Open" dialog box, if a floppy drive is connected, there is still a problem with reading: after inserting drive A, the DOS prompt still appears, prompting that drive B is not ready; if there is no floppy disk in drive A, a DOS interrupt error will directly occur, thus exiting the program.

Another point: I noticed that the "Up one level directory" button has been added to the open dialog box. Can the other several buttons be controlled? If the corresponding file is selected, can there be a message to notify the full path name of the currently selected highlighted item file for operations, such as preview processing?
Floor 236 Posted 2008-03-05 20:02 ·  中国 广东 深圳 宝安区 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
(1) The menu is enhanced to have F1 activate the first item of the menu, F2 activate the second item,..., F10 activate the tenth item.
(2) Regarding the issue of connecting a floppy drive, since I can't find a computer with a floppy drive around me, the code can't be tested. However, absread() is added, but when running under Windows, it always has an error with the error code "Permission denied".
(3) If using the "_bios_disk()" or "biosdisk()" function, it works in pure DOS, but when running under WinXP, it always prompts "Attempt to directly access the hard disk port".
(4) Hope that Brother "godai" can give some guidance.

[ Last edited by firstsail on 2008-3-6 at 09:10 AM ]
Floor 237 Posted 2008-03-06 15:29 ·  中国 广东 深圳 南山区 电信
初级用户
Credits 28
Posts 13
Joined 2008-02-18 12:33
18-year member
UID 110885
Gender Male
Status Offline
Hello, Brother Guo!

The program has been tested, and the menu functions are very easy to use. Thank you! :-)

Regarding the program to judge the floppy disk or USB flash drive, I will copy the segment of program I used before, hoping it can be a little help to Brother Guo:

Use the absread function to judge whether the USB flash drive ("D:") exists; (the hidden part is the program judged by _bios_disk):

BOOL IfUsbExist()
{//Judge whether the floppy disk exists
char buffer[512];
char ch[MAXPATH], ch1[50];
int Ifdrive = -1;
UINT nRetry;
char USBPATH[10];
strcpy(USBPATH, "D:"); //The D drive is the USB flash drive
char cDrive = toupper(USBPATH[0]) - 'A';
//struct diskinfo_t di;
//di.drive = toupper(USBPATH[0]) - 'C' + 0x80; //D drive USB
//di.head = 0;
//di.track = 0;
//di.sector = 1;
//di.nsectors = 1;
//di.buffer = buffer;

memset(buffer, 0, 512);
Ifdrive = absread(cDrive, 1, 2, buffer); //Re_bios_disk(_DISK_READ, &di);

//No USB flash drive
if (Ifdrive!= 0) return FALSE;

return TRUE;
}

BOOL IfFloppyExist()
{//Judge whether the floppy disk exists
char buffer[512];
struct diskinfo_t di;
int Ifdrive = -1;
char ch[MAXPATH], ch1[50];
UINT nRetry;
char FLOPPYPATH[10];
strcpy(FLOPPYPATH, "A:"); //The floppy disk is the A drive

memset(buffer, 0, 512);
strcpy(ch, FLOPPYPATH);
di.drive = toupper(ch[0]) - 'A';
di.head = 1;
di.track = 1;
di.sector = 1;
di.nsectors = 1;
di.buffer = buffer;

Ifdrive = Re_bios_disk(_DISK_READ, &di);

//No floppy disk
if (Ifdrive != 0) return FALSE;

return TRUE;
}


UINT Re_bios_disk(unsigned cmd, struct diskinfo_t _FAR *dinfo)
{//Retry _bios_disk for 3 times to avoid noise
UINT ret;
for (char i = 0; i < 3; i++)
{
ret = _bios_disk(cmd, dinfo) & 0xff00;
if (ret == 0)
break;
}

return ret;
}
Floor 238 Posted 2008-03-06 18:25 ·  中国 广东 深圳 宝安区 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
The function _bios_disk( cmd, dinfo ) under the following operating systems,

(1) Runs normally under pure DOS
(2) Runs normally under Win9x
(3) When running under Win2000/WinXP, it always pops up the error "Cannot directly access the hard disk port"

Preliminary analysis is that biosdisk or _bios_disk directly accesses interrupt 0x13 internally, resulting in system protection.

"Brother godai" please make it clear!

[ Last edited by firstsail on 2008-3-6 at 06:30 PM ]
Floor 239 Posted 2008-03-06 19:21 ·  中国 广东 深圳 南山区 电信
初级用户
Credits 28
Posts 13
Joined 2008-02-18 12:33
18-year member
UID 110885
Gender Male
Status Offline
Yes, I have also tried. There are such warnings when running under Win2000/WinXP because user operations at the BIOS level are prohibited under Win2000/WinXP. There is no problem running the _bios_disk function under pure DOS. This problem may not be bypassed under Win2000/WinXP at the BIOS level. When I originally programmed, I also used the macro definition __WINXP__ to compile two versions for running under Win2000/WinXP and pure DOS respectively, and haven't come up with a good way yet. :-)

But now the detection program under pure DOS also has a problem: if a floppy disk is inserted, the DOS prompt "diskette B not ready" will also appear. If there is no floppy disk inserted, it will more likely enter the DOS error interrupt INT25 and prompt disk fail or something like that, causing the system to crash. The practicality is not as good as before. If Brother Guo doesn't have a better way for the time being, it's better to go back to the previous version without detecting the floppy disk, heh heh.
Floor 240 Posted 2008-03-06 20:32 ·  中国 广东 深圳 宝安区 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
Temporarily restore no floppy disk detection, please re-download the update!

There is an idea: read the content of the 32-bit flag register. If the "VM flag", that is, the "virtual 8086 state flag", is "1", it means running under Windows, and do not use the biosdisk function to judge the existence of the floppy disk. If the flag is "0", it means running under pure DOS, and use the biosdisk function to judge the existence of the floppy disk.

But the "high 16 bits" of the flag register read by the following code is always "00000000", that is, it is impossible to know whether it is running under the "DOS virtual machine" forever. Brother "godai", is there any other method?

BOOL Is8086VM()
{
DWORD dwFlags;

__asm pushfd
__asm pop eax
__asm mov dwFlags, eax


return ((0 == (dwFlags & (1L << 17))) ? TRUE : FALSE);
}

[ Last edited by firstsail on 2008-3-6 at 08:33 PM ]
‹ Prev 1 14 15 16 17 18 20 Next ›
Forum Jump: