Hello everyone, I am Total (why is Total? Because my net name is "stealing online", everyone in the ancient city hotline is called me "secret", so I took an English homonym, it is Total, 嘿嘿 嘿嘿). In fact, I feel that I have no qualification to give you a lecture, and the purpose of writing teaching is that more original works will be seen in the forum.
I will not always write something, one is because the personal level is limited, one is because I am a communication engineer, but not a programmer, my primary work is still a good job of damaging the communication network, and the second is programming. Good Tell the time, start today's topic. As a meeting, tell you a high-level skill.
MapBasic Advanced Programming Tool Icon
Below is the original code of the program
'Program in Windows2000 English (SP4), MapInfo6.0 English version (SP1), Mapbasic 5.5 debugging
INCLUDE "mapbasic.def"
Declare Sub MAINDECLARE SUB TESTDLLCALLDECLARE FUNITRESDLL () AS String
Declare Function MyDLFUNC_W32 LIB "WIN32 / ICO32.DLL" ALIAS "MyParm AS Integer" AS INTEGER
DECLARE FUNCTION MYDLFUNC_W16 LIB "WIN16 / ICO16.DLL" ALIAS "MyParm AS Integer" AS INTEGER
Declare Function MYDLFUNC (BYVAL MYPARM AS INTEGER) AS INTEGER
Sub Main 'ö ÷ 3ìð d Dim icodll AS STRING
iCODLL = initresdll () Print Chr $ (12) Print "icotest program is loaded from" ApplicationDirectory $ () Print "Resource DLL IS" iCODLL
Create ButtonPad "icotest" As Toolbutton Calling Testdllcall Icon 138 File iCODLL CURSOR 136 File iCODLL TOOLBUTTON CALLING TESTDLLCALL ICON 134 File iCODLL CURSOR 136 File iCodllend Sub
Function InitResDLL () As String if (SystemInfo (SYS_INFO_MIPLATFORM) = MIPLATFORM_WIN16) Then InitResDLL = ApplicationDirectory $ () "win16 / ico16.dll" elseif (SystemInfo (SYS_INFO_MIPLATFORM) = MIPLATFORM_WIN32) Then InitResDLL = ApplicationDirectory $ () "win32 / Ico32.dll "else Note" This Application IS Not Supported On this Platform. "End Program End IFEND FUNCTION
Function MyDllFunc (ByVal myparm As Integer) As Integer if (SystemInfo (SYS_INFO_MIPLATFORM) = MIPLATFORM_WIN16) Then MyDllFunc = MyDllFunc_w16 (myparm) elseif (SystemInfo (SYS_INFO_MIPLATFORM) = MIPLATFORM_WIN32) Then MyDllFunc = MyDllFunc_w32 (myparm) else Note "This application is not supported On this Platform. "End Program End IFEnd FunctionGlobal Parmval As INTEGER
Sub TestdllCall
PARMVAL = PARMVAL 1
Print "The Answer IS:" STR $ (MyDLLFUNC (PARMVAL))
End Sub
The above code mainly comes from a MapBasic's own routine, so there is a ready-made stuff, don't have to do it yourself (oh ~~~~ Who is playing me ?? !!). It is difficult to write this procedure and It is not that the program is itself, but the generation of the DLL file. 1. Icon file format button icon file has strict requirements in Mapbasic. Icon file can only be bitmap format (BMP image format), size is small icon 18pixles Width 16pixles high, large icon 26pixles wide 24pixles high, small icon is used on the normal button, while the large icon is used after you choose to use the big button in mapInfo, editing editing editing icon Document, now add them to the DLL, we don't have to re-write a C language code to implement the generation of the DLL file, so you first C language. The method I said is to use the DLL file in the Mapbasic routine. . Use the resource editing software to open the DLL file, add the edited BMP file to the DLL, pay attention to the order of saving, first is a small bitmap, then a big bitmap, pay attention to the two files when naming two files must be connected, for example : Small icon is named 138, then the big icon should be named 139. Save the DLL. This is fine, you only need to modify the iCON number in the above program code to see your icon file.
OK, it's so much, there is anything that you have not cleared, you are welcome to ask and discuss.
Learn together and make progress together.
Total 2004.07.01 23:07 Written in Urumqi, Xinjiang