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

    #16
    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
    Marcel

    I hear and I forget. I see and I remember. I do and I understand.
    ---- Confusius ----

    Comment


      #17
      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

      Comment


        #18
        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
        Marcel

        I hear and I forget. I see and I remember. I do and I understand.
        ---- Confusius ----

        Comment


          #19
          RE: Example DLL translation from VBA into Xbasic

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

          I hear and I forget. I see and I remember. I do and I understand.
          ---- Confusius ----

          Comment


            #20
            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

            Comment


              #21
              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
              Marcel

              I hear and I forget. I see and I remember. I do and I understand.
              ---- Confusius ----

              Comment


                #22
                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.

                Comment


                  #23
                  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
                  Marcel

                  I hear and I forget. I see and I remember. I do and I understand.
                  ---- Confusius ----

                  Comment


                    #24
                    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
                    Marcel

                    I hear and I forget. I see and I remember. I do and I understand.
                    ---- Confusius ----

                    Comment


                      #25
                      RE: Example DLL translation from VBA into Xbasic

                      Hi Peter,

                      Try this one....

                      Code:
                      'Date Created: 27-Jun-2004 07:55:33 PM
                      'Last Updated: 28-Jun-2004 08:37:03 PM
                      'Created By  :
                      'Updated By  : 
                      
                      constant DISP_CHANGE_SUCCESSFUL	= 0
                      constant DISP_CHANGE_RESTART	= 1
                      constant DISP_CHANGE_BADFLAGS	= (-4)
                      constant DISP_CHANGE_FAILED	= (-1)
                      constant DISP_CHANGE_BADMODE	= (-2)
                      constant DISP_CHANGE_NOTUPDATED	= (-3)
                       
                      declarestruct _charbuf C32charbuf
                      declarestruct _charbufx C32charbufx
                      
                      'typedef struct _POINTL { 
                      '  LONG x; 
                      '  LONG y; 
                      '} POINTL, *PPOINTL;
                      
                      type POINTL
                      	x as I
                      	y as I
                      end type
                      
                      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
                      	dmPaperLength as Integer 'added
                      	dmPaperWidth as Integer
                      	dmScale as Integer
                      	dmCopies as Integer
                      	dmDefaultSource as Integer
                      	dmPrintQuality as Integer
                      	dmPosition as {POINTL}
                      	dmDisplayOrientation as Integer
                      	dmDisplayFixedOutput 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 
                      
                      'BOOL EnumDisplaySettings(
                      '  LPCTSTR lpszDeviceName,  // display device
                      '  DWORD iModeNum,          // graphics mode
                      '  LPDEVMODE lpDevMode      // graphics mode settings
                      ');
                      declare USER32 EnumDisplaySettings@EnumDisplaySettingsA LLL(DEVMODE)
                      
                      'LONG ChangeDisplaySettings(
                      '  LPDEVMODE lpDevMode,  // graphics mode
                      '  DWORD dwflags         // graphics mode options
                      '); 
                      declare USER32 ChangeDisplaySettings@ChangeDisplaySettingsA L(DEVMODE)L
                      
                      change_res(800, 600)
                      undeclare EnumDisplaySettings
                      undeclare ChangeDisplaySettings
                      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
                      	'debug(1)
                      	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
                      My screen got black and came back with DISP_CHANGE_FAILED. This is a good start.

                      Marcel
                      Marcel

                      I hear and I forget. I see and I remember. I do and I understand.
                      ---- Confusius ----

                      Comment


                        #26
                        RE: Example DLL translation from VBA into Xbasic

                        The union in this structure is a|the problem. For a union is as many room reserverd as its largest member of the union. In case of the first union: the struct {..} is valid or dmPosition or dmDisplayOrientation or dmDisplayFixedOutput. Obvious the struct is the largest and if a short is 16 bit there must be room for 8 x 16 = 128 bits (16 bytes). So we must create a patchwork for this.

                        The last part of the structure are conditional compiler directives and must be examined it may be part of the structure in our case.

                        If I am wrong please correct me.

                        Regards,

                        Marcel

                        Code:
                        typedef struct _devicemode { 
                          BCHAR  dmDeviceName[CCHDEVICENAME]; 
                          WORD   dmSpecVersion; 
                          WORD   dmDriverVersion; 
                          WORD   dmSize; 
                          WORD   dmDriverExtra; 
                          DWORD  dmFields; 
                          union {
                            struct {
                              short dmOrientation;
                              short dmPaperSize;
                              short dmPaperLength;
                              short dmPaperWidth;
                              short dmScale; 
                              short dmCopies; 
                              short dmDefaultSource; 
                              short dmPrintQuality; 
                            };
                            POINTL dmPosition;
                            DWORD  dmDisplayOrientation;
                            DWORD  dmDisplayFixedOutput;
                          };
                        
                          short  dmColor; 
                          short  dmDuplex; 
                          short  dmYResolution; 
                          short  dmTTOption; 
                          short  dmCollate; 
                          BYTE  dmFormName[CCHFORMNAME]; 
                          WORD  dmLogPixels; 
                          DWORD  dmBitsPerPel; 
                          DWORD  dmPelsWidth; 
                          DWORD  dmPelsHeight; 
                          union {
                            DWORD  dmDisplayFlags; 
                            DWORD  dmNup;
                          }
                          DWORD  dmDisplayFrequency; 
                        #if(WINVER >= 0x0400) 
                          DWORD  dmICMMethod;
                          DWORD  dmICMIntent;
                          DWORD  dmMediaType;
                          DWORD  dmDitherType;
                          DWORD  dmReserved1;
                          DWORD  dmReserved2;
                        #if (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400)
                          DWORD  dmPanningWidth;
                          DWORD  dmPanningHeight;
                        #endif
                        #endif /* WINVER >= 0x0400 */
                        } DEVMODE;
                        Marcel

                        I hear and I forget. I see and I remember. I do and I understand.
                        ---- Confusius ----

                        Comment


                          #27
                          RE: Example DLL translation from VBA into Xbasic

                          Well, Marcel, I got it to work, but I can't explain why.
                          Here it goes, for my notebook, which supports 1024x768 or 800x600 mode with either 16 or 32 bits/pixel:
                          Code:
                          constant DISP_CHANGE_SUCCESSFUL	= 0
                          constant DISP_CHANGE_RESTART	= 1
                          constant DISP_CHANGE_BADFLAGS	= (-4)
                          constant DISP_CHANGE_FAILED	= (-1)
                          constant DISP_CHANGE_BADMODE	= (-2)
                          constant DISP_CHANGE_NOTUPDATED	= (-3)
                           
                          declarestruct _charbuf C32charbuf
                          
                          
                          
                          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
                          	dmPaperLength 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
                          	dmBitsPerPel as Integer
                          	dmPelsWidth as Integer
                          	dmPelsHeight as Integer
                          	dmDisplayFlags as Integer
                          	dmDisplayFrequency as Integer
                          	dmICMMethod as Integer
                          	dmICMIntent as Integer
                          	dmMediaTYpe as Integer
                          	dmDitherTYpe as Integer
                          	dmReserved1 as Integer
                          	dmReserved2 as Integer
                          	dmPanningWidth as Integer
                          	dmPanningHeight as Integer
                          end type 
                          
                          
                          declare USER32 EnumDisplaySettings@EnumDisplaySettingsA LLL(DEVMODE)
                          
                          declare USER32 ChangeDisplaySettings@ChangeDisplaySettingsA L(DEVMODE)L
                          
                          change_res(800, 600)
                          undeclare EnumDisplaySettings
                          undeclare ChangeDisplaySettings
                          end
                          
                          function change_res(width as n, height as n)
                          	CONSTANT DM_PELSWIDTH = hex_to_dec("80000")
                          	constant DM_PELSHEIGHT = hex_to_dec("100000")
                          	CONSTANT DM_BITSPERPEL = hex_to_dec("40000")
                          	
                          	dim DevM as {DEVMODE}
                          	
                          	'dim displaymodes[100] as c
                          	'debug(1)
                          	dim disp as n
                          	disp=1
                          	i=0
                          	while disp > 0 
                          		disp= EnumDisplaySettings(0,i,DevM)
                          		i=i+1
                          		'displaymodes[i]=property_to_string(DevM)
                          	end while
                          '	for j=23 to i
                          '		ui_msg_box(""+(j-1),displaymodes[j])
                          '	next	
                          	DevM.dmFields = DM_PELSWIDTH .or. DM_PELSHEIGHT .or. DM_BITSPERPEL
                          	DevM.dmPelsWidth = width
                          	DevM.dmPelsHeight = height
                          	DevM.dmSize=8126592
                          	DevM.dmbitsperpel=32
                          	DevM.dmDisplayFrequency=60
                          	b = ChangeDisplaySettings(DevM, 0)
                          	ui_msg_box("b",""+b)
                          end function
                          As you can see I removed a number of elements from the C structure. Don't ask me why it works, because I don't know. Maybe at another time I can figure it out.

                          Comment


                            #28
                            RE: Example DLL translation from VBA into Xbasic

                            Hi Peter,

                            Indeed, very strange but it works well on my Dell desktop. It need some backwards investigation as you said. The solution will be somewhere in the API text and is always a matter of reading...

                            Thanks, I learned a lot because your example brought the solution to mine. I used the properties function to examine the structure. It works now.

                            Regards,

                            Marcel
                            Marcel

                            I hear and I forget. I see and I remember. I do and I understand.
                            ---- Confusius ----

                            Comment


                              #29
                              RE: Example DLL translation from VBA into Xbasic

                              Marcel,

                              I think the issue may be the sizes of variables in Xbasic and C. I think that the confusion arises because they each use the same words for different things. In that case, all I did was keep hacking away at the structure of DEVMODE until I got one where the width and height were in the right place.

                              Thanks for your help on this one.
                              Regards,
                              Peter

                              Comment


                                #30
                                RE: Example DLL translation from VBA into Xbasic

                                Aha. The issue is that the Xbasic integer is 4 bytes long, while the VB integer is 2 bytes long. The structure I came up with was just the right size to compensate, even though the individual elements of the structure make no sense between the display name and near the end where bits/pixel and height and width are stored.

                                Comment

                                Working...
                                X