|
Answered Questions For Jan/Feb 2002
Here is an example: FindWindow()
Option Explicit I hope this helps.
|
|
VB & Unicode?From: prof.Sorin Olteanu
|
Application/Operating System |
How It Handles Strings |
Visual Basic 5/6 | Visual Basic uses Unicode to store and manipulate strings |
Windows 95/98/ME | Uses ANSI or DBCS to store and manipulate strings. |
Windows NT/2000/XP | Uses Unicode to store and manipulate strings. |
Automation in Windows 95/98/ME & NT/2000/XP | Uses Unicode to pass the strings back and forth. |
Windows 95/98/ME API calls | Uses ANSI |
Windows NT/2000/XP API calls | Uses Unicode |
Now, there are exceptions to the rules,
any API call with an “A” on the end means it is an ANSI
function call and any string passed to it will be treated as
such. Any API call with a “W” on the end means it is a
“Wide” call and the strings passed will be treated and
manipulated as Unicode. Any call without either an “A” or a
“W” will be treated as the operating system dictates. (Win
95/98/ME = ANSI, Win NT/2000/XP = Unicode)
Now, I have not used Greek or Sanskrit alphabets, but the
text within VB and the controls are being stored as Unicode,
no matter what OS you are using. I think the problem you are
having stems from the type of font you are using. The
default font for a control is MS Sans Serif, a non-True Type
font with only one script, Western. If you change the font
to something like Time New Roman, and then change the
“script” property, you are open to all sorts of character
sets, for example, Greek, Arabic, Turkish, Cyrillic and a
few more.
If this still does not work, let me know, there are API
calls that may do it, but you would have get the handle to
the control, get the text, call the API to “Paste” it into a
control and I think that is a lot of over head.
I hope this helps.
I have a second problem and I ask again for your help (am I abusing?): 1. I need to make typing manager using Unicode characters (for ancient greek, polytonic). I learned how to set a general hook to intercept keystrokes, by subclassing, but I don't understand this: after processing the keyboard stroke, how do I send it back to the current application and how can I modify the text already edited? Could you also give me a short sample code (VB5 under Windows98)?
I really do not think you will need to
do the sub classing, when you read my response to your
first question, you will see that by changing the font
properties, the control will automatically display Greek
characters.
One more thing, instead of doing all of that sub
classing, you could have just written code in the
KeyDown event of the control, this event tells you the
key that was pressed and a bitmask telling you other
keys as well, for example, if the user also pressed the
Shift or Ctrl key along with the character key. You can
also directly manipulate the text entered or even
existing right from this event.
Note: I did not recommend the KeyPress event because it
only fires when the user presses an ANSI key on the
keyboard and only passes the ANSI key code.
I hope this helps
Hi. Just tried to post a question in
your VB Questions section, and the site seemed to bomb
out when I clicked submit, so I thought I'd submit my
question this way! :-)
I have written a program that allows you to choose from
more display modes than windows XP makes available. It
runs on startup by putting a link to it in the registry
key "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
but it seems to load before windows has finished loading
user settings, which causes a problem when the program
tries to change display modes
Do you know of any way I can make my program wait for
WinXP to finish loading the user settings etc.(and make
sure the desktop is displayed) before it tries to do any
mode changes?
Regards,
Jim diGriz
Hi Jim,
First of all, I want to apologize for the question page crapping out, Tripod has done something to their site and I have had problems all over the place, from formatting changes and URL name changes to pages just disappearing. Any page that submits data is severely effected, so I have written some scripts on the page to correct it, for now anyway.
OK, now on to your question. This was
a tuff one, but I think I may have your answer. I
started looking for an API that would tell me if Windows
had finished loading, unfortunately, there is no such
call (documented anyway). So I tried a different angle,
I found an API call that returns the handle of the
desktop, if it finds the desktop it returns a non-zero
number, if it fails (the desktop is not loaded yet) it
returns 0. I tried it and it seems to work OK, so here
you go…
Paste this API call into the declares section of your
form or BAS file:
Private Declare Function GetDesktopWindow Lib
"user32.dll" () As Long
'GetDesktopWindow returns a handle to the desktop
window. The desktop window is the window that makes up
the desktop of the computer -- that is, the screen. If
the function fails, it will return 0 instead of the
handle.
Next, past this code, or modify it to your needs into
the form load Event or Sub Main call:
' Find the device context of the desktop
Dim deskhwnd As Long ' handle to the desktop
Do While deskhwnd = 0
DoEvents
deskhwnd = GetDesktopWindow() ' get the desktop's handle
Loop
I hope this helped
Can you please tell me how to make program for MS-DOS using VB.
Sorry Mohamed, you can not use the VB compiler to create MS DOS applications. There are a few reasons for this, for one, DOS is a 16 bit operating system and VB 4,5 and 6 are 32 bit compilers. The next reason is DOS programming and Windows programming are two completely different styles. In DOS programming it is called procedural, you define a main program loop and keep checking for user input, branching off when the user enters a correct response. In Windows programming, it is called event development. The operating system will keep the program alive as long as the program keeps checking it message queue for events. The operating system will place events (mouse clicks or mouse movements) into the the programs event queue. As long as you have defined code to handle that event, that events code will run.
So, as you can see, not only are the programming methods different, but a Windows compiler is completely different from a DOS compiler
Hi,
I read your tutorial on UDL and I am very interested if
there is any way of adding a Provider in Data link
properties. I am interested in linking KDB database.
Please help if you know how to do it.
Thanks
Jolanta
Hi Jolanta,
The only way to add a provider is to install an OLE DB
or ODBC type driver for that database to your system.
Microsoft is the best place to start looking to see if
there is a driver available for your database, as they
are the ones that write most of them, including
databases like Oracle. To point you in the right
direction, here is the link to the
Microsoft Universal Data Access Web Site.
I hope this helps
Hey,
I have recently finished a program that will be distributed over the internet in a shareware like
fashion. I was wondering if you know any good ways to code for the 30 day trial period expire, and to create a
key generator if they call and purchase the program??
if you have any ideas i would love to hear them..
Thanks,
//Tim
Hey Tim,
The best way to do the 30 day trial period is to create some obscure
registry setting name with 2 keys, Date (the
installation date) and CD Key (the license number).
When your setup application installs your app, have it
check for this registry setting. If it is all ready
there, check the values, if it is not registered (only
the default CD key) and more then 30 days are up, do not
let the setup continue, or have the setup ask for a
valid key (one they bought from you) before it will
continue. Also have your application check these
values every time it starts up, if 30 days are gone by,
then do not let it start. Have your setup program
leave the registry entries when the user un-installs
your app, this way if 30 days have passed and they try
to un-install and then re-install the app again, it will
still not work. The only way they can get your
application to re-install again is to either buy the
program or scrub their computer. But make sure the
user would never know the registry settings are for your
program, even if they were to search the registry
manually, or else they will be able to roll back the
date field them selves.
A key generator is a little more difficult, it must be an algorithm that is decided upon for both the application and your generator. How I would do it is like this, decide how many characters (numbers and letters) the key should be first, then decide if the first char should be a letter or a number. That fist letter or number can only be within a certain range say a,b or c for letters or 7,8 or 9 for numbers. The next char can only be a certain letter or number depending on the last letter or number, then repeat.
So, say you decide the first char can only be a letter between A and D and the second char is a number, if the user enters A, then the second char can only be a 6, B then only a 9 and keep repeating this algorithm until you reach the maximum number of chars in the CD key.
As I said, this is how I would do it, it probably is not the be the best way of doing it, I would poke around the Net to see if their are more examples.
I hope this helps
Send mail to WebMaster with
questions or comments about this web site.
|