Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Example DLL translation from VBA into Xbasic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Marcel Kollenaar
    replied
    RE: Example DLL translation from VBA into Xbasic

    Peter,

    Is it possible to use BLOB's? A blob can be peeked and poked in byte, word and dword to investigate its contents.

    A blob can be used in a TYPE..END TYPE. But can it also get the raw binary data?

    Just some ideas..

    Marcel

    Leave a comment:


  • Marcel Kollenaar
    replied
    RE: Example DLL translation from VBA into Xbasic

    Thanks Peter, I'll inform you if I do have some progress to this matter.

    Sometimes my progress is 10 bytes longs and a structure backwards ;-)

    Regards,

    Marcel

    Leave a comment:


  • Peter.Wayne
    replied
    RE: Example DLL translation from VBA into Xbasic

    Marcel,
    I agree with you, it's almost impossible in Xbasic. I'm going to give up for now. We need some guidance from the developers.

    Leave a comment:


  • Marcel Kollenaar
    replied
    RE: Example DLL translation from VBA into Xbasic

    Ditto.

    You hit the same wall as I do. In your case you get the first few parameters. That's something to celebrate. I miss the clear and exact way of declaring structures from C. A byte is a byte and an Int is a integer.

    Here in Xbasic I really don't know what I am doing. I'm complete blind. No function to support this constructs and working with it. Too much asuming that it will fit into the structure (mask) you declare. No differences between byte (BYTE) 8bit, short(WORD) 16bit, integer(DWORD) 32bit. I've no idea how this is done insite Xbasic.

    I miss such tools as sizeof(DEVMODE) to get the real size of structures. Some structures need that. This one does also. Here some explanation from the SDK.

    Quote....
    dmSize
    Specifies the size, in bytes, of the DEVMODE structure, not including any private driver-specific data that might follow the structure's public members. Set this member to sizeof(DEVMODE) to indicate the version of the DEVMODE structure being used.
    ...QuteEnd

    So far I have no solution. Maybe that Selwyn, Aaron or Lenny can clearify something. It cost too much time to puzzle this out in Xbasic. Sometimes I build a dll in PureBasic and handle such stuff in a simplyfied external function like I did in PbAttrib.dll. There I can get the right members back in structures or there are some functions defined that do the job.

    I'll still take a look at your code.

    Marcel

    Leave a comment:


  • Peter.Wayne
    replied
    RE: Example DLL translation from VBA into Xbasic

    Marcel,
    You're right, I left out a member of the structure. I got the specs from the Microsoft site and I left out that member.
    I may try to rewrite the type...end type as a structure, but I find the structure syntax so confusing that I try to avoid it whenever possible.
    When I run the EnumDisplaySettings, I get the video card adapter name, and the next 2 parameters, but everything else is blank or zero. Is that what you get as well?
    And yes, I get -2 back when I try to change the settings, but of course, I'm trying to change them to blank settings, for the most part, which causes the error.
    - Peter

    Leave a comment:


  • Marcel Kollenaar
    replied
    RE: Example DLL translation from VBA into Xbasic

    Peter, do you also getting DISP_CHANGE_BADMODE (-2) in b back as a result?

    Leave a comment:


  • Marcel Kollenaar
    replied
    RE: Example DLL translation from VBA into Xbasic

    Hi Peter,

    Yes, I'm aware of it, it's very obscure.

    A question about your code:

    From which version of Windows Software Development Kit (WINAPI) did you get the structure information? I have two versions.

    1 The Microsoft Plaform SDK February 2003.
    2 The Win32 programmers Reference from Borland C++ Builder 6.

    Both are different. Number 1 (newer) shows a union in it which is not precent at 2 (older). The union differs because it is a structure which is used for screen or printer. The union can make the problem. The size depends on the biggest member(s) in it.

    I think the structure is incomplete. I added - dmPaperLength as Integer - to the structure.

    I'll continue my investigation.

    Marcel

    Leave a comment:


  • Peter.Wayne
    replied
    RE: Example DLL translation from VBA into Xbasic

    Marcel,
    I doubt the problem is that we can't do it in Xbasic, but rather that we don't know how to do it in Xbasic. The syntax is, as you know, obscure!
    - Peter

    Leave a comment:


  • Marcel Kollenaar
    replied
    RE: Example DLL translation from VBA into Xbasic

    Peter,

    I'll take a look at your code. Maybe it answers some question I have and can help you.

    In the meantime I post here some stuff where I don't know why I can't get WIN32_FIND_DATA structure filled. I'm translating this from the Win32 Programmer's Reference. It was code I'd examined several months ago to overcome some problems with the File Attributes command. Here are some problems such as translating the array[] construction in a c-type declaration. Xbasic doesn't do this job. Another point is how can I pass the WIN32_FIND_DATA by reference so the function can fill the structure.

    It is also possible that I'm trying something to do that can't be done in Xbasic simple because the structure translating lacks. However here some premature code.

    Code:
    'Purpose
    'Trying to get the structure WIN32_FIND_DATA filled by dll function FindFirstFileA().
    'Possible problems will arise with the array based structure members.
    'Question:
    '- How is a - TCHAR cAlternateFileName[14] - structure part handled by Xbasic.
    '  in C this is a array of 14 characters closed with a \0
    
    constant MAX_PATH = 260
    '#define INVALID_HANDLE_VALUE	(HANDLE)(0xffffffff) 'This is C
    constant INVALID_HANDLE_VALUE = hex_to_dec("ffffffff") 
    
    'C-code
    'The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
    
    'typedef struct _FILETIME {
    '	DWORD dwLowDateTime;
    '	DWORD dwHighDateTime;
    '} FILETIME, *PFILETIME;
    
    'Xbasic version
    type FILETIME
    	dwLowDateTime as Integer
    	dwHighDateTime as Integer
    end type
    
    'C-code
    'The WIN32_FIND_DATA structure describes a file found by the FindFirstFile, FindFirstFileEx, or FindNextFile function.
    
    'typedef struct _WIN32_FIND_DATA {
    '  DWORD dwFileAttributes;
    '  FILETIME ftCreationTime;
    '  FILETIME ftLastAccessTime;
    '  FILETIME ftLastWriteTime;
    '  DWORD nFileSizeHigh;
    '  DWORD nFileSizeLow;
    '  DWORD dwReserved0;'
    '  DWORD dwReserved1;
    '  TCHAR cFileName[MAX_PATH];
    '  TCHAR cAlternateFileName[14];
    '} WIN32_FIND_DATA, *PWIN32_FIND_DATA;
    
    'Xbasic version
    'Note Using Arrays are not allowed in a structure.. Is this sitting Duck or not?
    type WIN32_FIND_DATA
      dwFileAttributes as Integer
      ftCreationTime as {FILETIME}
      ftLastAccessTime as {FILETIME}
      ftLastWriteTime as {FILETIME}	'This is allowed
      nFileSizeHigh as Integer
      nFileSizeLow as Integer
      dwReserved0 as Integer
      dwReserved1 as Integer
      cFileName as C
      cAlternateFileName as C
    '  cAlternateFileName[14] as Byte 'This doesn't work.
    end type
    
    'Declare the external functions in KERNEL32.DLL
    'The FindFirstFile function searches a directory for a file whose name matches the specified file name.
    'FindFirstFile examines subdirectory names as well as file names. The FindFirstFile function opens a search
    'handle and returns information about the first file whose name matches the specified pattern. It searches 
    'both the long and short file names. After the search handle has been established, use the FindNextFile 
    'function to search for other files that match the same pattern. When the search handle is no longer needed, 
    'close it by using the FindClose function
    
    declare KERNEL32 FindFirstFileA LC(WIN32_FIND_DATA)
    
    'The FindClose function closes the specified search handle. The FindFirstFile, FindFirstFileEx, and FindNextFile
    'functions use the search handle to locate files with names that match a given name.
    
    declare KERNEL32 FindClose LL
    
    dim hFind as N	'Search handle 
    dim filepointer as P 'Create a pointer for passing the filename to the function.
    
    'Give the WIN32_FIND_DATA structure a memory mask.
    dim findfiledata as {win32_find_data}
    dim filepointer.filename as C
    dim findfiledata.wFileAttributes as N
    dim findfiledata.ftCreationTime as {FILETIME}
    dim findfiledata.ftLastAccessTime as {FILETIME}
    dim findfiledata.ftLastWriteTime as {FILETIME}
    dim findfiledata.nFileSizeHigh as N
    dim findfiledata.nFileSizeLow as N
    dim findfiledata.dwReserved0 as N
    dim findfiledata.dwReserved1 as N
    dim findfiledata.cAlternateFileName as C
    
    'Initialize.
    filepointer.filename = ""
    findfiledata.wFileAttributes = 0
    findfiledata.ftCreationTime.dwLowDateTime = 0
    findfiledata.ftCreationTime.dwHighDateTime = 0
    findfiledata.ftLastAccessTime.dwLowDateTime = 0
    findfiledata.ftLastAccessTime.dwHighDateTime = 0
    findfiledata.ftLastWriteTime.dwLowDateTime = 0
    findfiledata.ftLastWriteTime.dwHighDateTime = 0
    findfiledata.nFileSizeHigh = 0
    findfiledata.nFileSizeLow = 0
    findfiledata.dwReserved0 = 0
    findfiledata.dwReserved1 = 0
    findfiledata.cAlternateFileName = ""
    
    'debug(1)
    filepointer.filename = "C:\\*.*"	'Whatever there is find the first.
    
    hFind = FindFirstFileA(filepointer,findfiledata) '
    
    if hFind = INVALID_HANDLE_VALUE then
    
    	ui_msg_box("Error", "INVALID_HANDLE_VALUE")
    
    else
    
    	ui_msg_box("Succeed", "HANDLE_VALUE_OK")
    	ui_msg_box("hFind", convert_type(hFind, "C"))
    	ui_msg_box("Filename", convert_type(findfiledata.cFileName, "C"))
    	ui_msg_box("INVALID_HANDLE_VALUE", convert_type(INVALID_HANDLE_VALUE, "C"))
    	ui_msg_box("wFileAttributes", convert_type(findfiledata.wFileAttributes, "C"))
    	ui_msg_box("dwLowDateTime", convert_type(findfiledata.ftCreationTime.dwLowDateTime, "C"))
    	
    	FindClose(hFind)
    	
    end if	
    
    undeclare FindFirstFile
    undeclare FindClose
    
    End

    Leave a comment:


  • Peter.Wayne
    replied
    RE: Example DLL translation from VBA into Xbasic

    Marcel,
    Maybe you would like to try your hand at something that has stumped me since yesterday. I want to change the display resolution from within A5. Here is what I have done so far, but it doesn't work properly:

    Code:
    declarestruct charbuf C32charbuf
    declarestruct charbufx C32charbufx
    
    type DEVMODE
    dmDeviceName as charbuf
    dmSpecVersion as Integer
    dmDriverVersion as Integer
    dmSize as Integer
    dmDriverExtra as Integer
    dmFields as Integer
    dmOrientation as Integer
    dmPaperSize as Integer
    dmPaperWidth as Integer
    dmScale as Integer
    dmCopies as Integer
    dmDefaultSource as Integer
    dmPrintQuality as Integer
    dmColor as Integer
    dmDuplex as Integer
    dmYResolution as Integer
    dmTTOption as Integer
    dmCollate as Integer
    dmFormName as charbufx 
    dmLogPixels as Integer
    dmBitsPerPel as Integer
    dmPelsWidth as Integer
    dmPelsHeight as Integer
    dmDisplayFlags as Integer
    dmDisplayFrequency as Integer
    end type 
    
    
    declare USER32 EnumDisplaySettings@EnumDisplaySettingsA LLL(DEVMODE) 
    declare USER32 ChangeDisplaySettings@ChangeDisplaySettingsA L(DEVMODE)L
    
    change_res(800, 600)
    end
    
    function change_res(width as n, height as n)
    	CONSTANT DM_PELSWIDTH = hex_to_dec("80000")
    	constant DM_PELSHEIGHT = hex_to_dec("100000")
    	
    	dim DevM as {DEVMODE}
    
    	'dim displaymodes[100] as c
    	
    	dim disp as n
    	disp=1
    	i=0
    	while disp>0 '.and. i
    		disp= EnumDisplaySettings(0,i,DevM)
    		i=i+1
    		'displaymodes[i]=property_to_string(DevM)
    	end while
    	'for j=1 to i
    	'	ui_msg_box(""+(j-1),displaymodes[j])
    	'next	
    	DevM.dmFields = DM_PELSWIDTH .or. DM_PELSHEIGHT
    	DevM.dmPelsWidth = width
    	DevM.dmPelsHeight = height
    	b = ChangeDisplaySettings(DevM, 0)
    	'ui_msg_box("b",""+b)
    end function
    If you uncomment the commented sections you wll see that EnumDisplaySettings does not return all properties--particularly, the BitsPerPel (PerPixel) is zero. So I'm clearly doing something wrong in the calling convention.

    Leave a comment:


  • Finian Lennon
    replied
    RE: Example DLL translation from VBA into Xbasic

    Martin:

    In the cmd files I always enclose the path to the files within quotes, whether they contain spaces or not and regardless of the length. This seems to work fine.

    Finian

    Leave a comment:


  • martinwcole
    replied
    RE: Example DLL translation from VBA into Xbasic

    Thanks to you both.
    Peter, it doesn't work.
    The solution may be to have single word, max 8 character length folder names

    Leave a comment:


  • Finian Lennon
    replied
    RE: Example DLL translation from VBA into Xbasic

    Martin:

    Duh! Sorry.

    I use this stuff in our upgrade application. I need to get the upgrade path and source files path from the user. I then create batch (cmd) files in xbasic to run the various processes. This is where sys_shell_wait will be a great simplifier. I think sys_shell_wait is built in to V6 but all my stuff is still in V5.

    Anyway, I created a cmd file in Textpad called "copyfiles.cmd". In my test it has just one line:
    xcopy "C:\OSOM Data\OMSCompV5\*.*" "C:\OSOM Data\temp\*.*" /E /Y

    I used Peter's script pretty much as is:

    command="C:\OSOM Data\OMSCompv5\copyfiles.cmd"
    sys_shell_wait(command,.F.)
    ui_msg_box("","Copyfiles was closed")
    end

    When run, this copies the files with no window showing.

    Finian

    with the command lines. Sometimes they are just one line

    Leave a comment:


  • Peter.Wayne
    replied
    RE: Example DLL translation from VBA into Xbasic

    sorry, forget to check the "use html" box:
    Code:
    sys_shell_wait("xcopy c:\alpha\newha\Practic~\*.* c:\alpha\newha\test34\*.* /E /Y",.t.)

    Leave a comment:


  • Peter.Wayne
    replied
    RE: Example DLL translation from VBA into Xbasic

    try this, Martin:
    "pre"
    sys_shell_wait("xcopy c:\alpha\newha\Practic~\*.* c:\alpha\newha\test34\*.* /E /Y",.t.) "/pre"

    Leave a comment:

Working...
X