|
-
Jun 28th, 2004, 04:25 AM
#1
Help with a structure declaration please
FROM MSDN...
JOYCAPS
The JOYCAPS structure contains information about the joystick capabilities.
typedef struct {
WORD wMid;
WORD wPid;
CHAR szPname[32];
UINT wXmin;
UINT wXmax;
UINT wYmin;
UINT wYmax;
UINT wZmin;
UINT wZmax;
UINT wNumButtons;
UINT wPeriodMin;
UINT wPeriodMax;
UINT wRmin;
UINT wRmax;
UINT wUmin;
UINT wUmax;
UINT wVmin;
UINT wVmax;
UINT wCaps;
UINT wMaxAxes;
UINT wNumAxes;
UINT wMaxButtons;
CHAR szRegKey[32];
CHAR szOEMVxD[260];
} JOYCAPS;
Can someone tell me how to declare this structure in VB please?
I am trying to update an API call taht was originally coded in VB6 and now I have translated that into VB.net. But the extended version of that structure is as outlined above and I need to use that instead.
I cannot find any examples of VB.net code for this. I think I'd need to use some kind of <attribute> tag but I am at a loss.
Maybe one of you gurus can help? Its mainly the 3 CHAR arrays that I am having trouble with.
I don't live here any more.
-
Jun 28th, 2004, 08:34 AM
#2
yay gay
Instead of char arrays put StringBuilders and set it's max capacity to the desired numbers
\m/  \m/
-
Jun 28th, 2004, 10:34 AM
#3
Lively Member
You could also have members of your structure as arrays of Byte's where the structure has CHAR arrays and then do the conversion to a string for your use...not real efficient, but would probably work well enough...
HTH
Hume
-
Jun 28th, 2004, 02:50 PM
#4
I couldn't use stringbuilders, but the helpful error message that it prompted told me to use strings instead and initialise them in a certain manner, which I did.
This is what I now have:
VB Code:
Private Structure JOYCAPS
Dim Mid As Short
Dim Pid As Short
Dim Pname As String
Dim Xmin As Integer
Dim Xmax As Integer
Dim Ymin As Integer
Dim Ymax As Integer
Dim Zmin As Integer
Dim Zmax As Integer
Dim NumButtons As Integer
Dim PeriodMin As Integer
Dim PeriodMax As Integer
Dim Rmin As Integer
Dim Rmax As Integer
Dim Umin As Integer
Dim Umax As Integer
Dim Vmin As Integer
Dim Vmax As Integer
Dim Caps As Integer
Dim MaxAxes As Integer
Dim NumAxes As Integer
Dim MaxButtons As Integer
Dim RegKey As String
Dim OEMVxD As String
End Structure
But when I call the function with this structure (after initialising relevant properties) I get a return (error) code of 165. I have no idea what this code means and apparently no means of finding out. It could be anything from an unexpected data structure, to ANYTHING.
I can't believe MSDN just leaves this structure like this without further info.
Any ideas guys?
I don't live here any more.
-
Jun 28th, 2004, 02:57 PM
#5
Lively Member
Try this...Make your RegKey an Array of Bytes (and any other strings as well, assuming this is a C Type structure)
...
RegKey(32) as Byte
...
Then inside whatever routine you are writing, you will need to assemble a string based on the Byte indexes using the ASC function
Also, the UINT could give you problems as well, since this is an unsigned INT which VB doesn't have. It is not the same as an Integer or Short.
Lastly, I'm not sure if it will let you have a Structure member named Mid (since this is an intrinsic VB function)
HTH
Hume
-
Jun 28th, 2004, 03:08 PM
#6
Lively Member
Sorry, should use the Chr function, not the Asc...
-
Jun 28th, 2004, 03:12 PM
#7
Frenzied Member
Also, the UINT could give you problems as well, since this is an unsigned INT which VB doesn't have. It is not the same as an Integer or Short.
Not true, System.uint16 and system.uint32. I would try using these for the WORD and UINT variables as Short and Integer are both signed variables.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jun 28th, 2004, 03:24 PM
#8
I'm not bothered about the actual contents of the char arrays. I just need to get the structure compatible with the API call first. I tried your suggestion, it compiles without error, but it still returns the mystery 165 code.
Most puzzling.
I don't live here any more.
-
Jun 28th, 2004, 03:28 PM
#9
Frenzied Member
Have you looked at this line
Dim Mid As Short
Mid seems to be a keyword, maybe that is messing you up? Not sure.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jun 28th, 2004, 03:29 PM
#10
Lively Member
Sean,
How do I do that in VB6.0? VB.NET, no problem, but I'm not sure how to access that in 6.0...
-
Jun 28th, 2004, 03:43 PM
#11
Lively Member
Whoops, wrong forum. Thought this one was in Visual Bsaic Classic...sheepish grin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|