LPTSTR, typedef, and pointers HELP

Hi everyone, can someone help me with the following code

Code:

typedef unsigned short WCHAR;
typedef WCHAR *LPWSTR, *PWSTR;
typedef LPWSTR LPTSTR; //typedef lines are from winnt.h

/*Global Variable*/
int trial = 0;

function(.......)
{
WCHAR s1,s2;
HWND hctl_data, hctl_type;

Edit_SetText(hctl_data, (LPTSTR)(something));
trial++;
s2 = s1;
s1 = *(LPTSTR)(something);

if(trail > 2)
{
trial = 0;
if( s1 == s2)
{
Edit_SetText(hctl_type, TEXT("working");
}
}
}

Code ends:

The Edit_SetText(HWND hWnd, LPTSTR lpString) is similar to the SetWindowText function (actually it was #define). The Edit_SetText function works. Edit_SetText(hctl_type, TEXT("working")) will print out "working".

My questions and problems are in regards to s1 and s2.
Is s1 = *(LPTSTR)(something); correct?
How do I get the unsigned short value out of (LPTSTR)(something)?
My goal is to compare two (LPTSTR)(something). Is there a function in does this, comparing two LPTSTR values?

Thx in advance

Comments

  • You do know that is a VB forum not C++.

    : Hi everyone, can someone help me with the following code
    :
    : Code:
    :
    : typedef unsigned short WCHAR;
    : typedef WCHAR *LPWSTR, *PWSTR;
    : typedef LPWSTR LPTSTR; //typedef lines are from winnt.h
    :
    : /*Global Variable*/
    : int trial = 0;
    :
    : function(.......)
    : {
    : WCHAR s1,s2;
    : HWND hctl_data, hctl_type;
    :
    : Edit_SetText(hctl_data, (LPTSTR)(something));
    : trial++;
    : s2 = s1;
    : s1 = *(LPTSTR)(something);
    :
    : if(trail > 2)
    : {
    : trial = 0;
    : if( s1 == s2)
    : {
    : Edit_SetText(hctl_type, TEXT("working");
    : }
    : }
    : }
    :
    : Code ends:
    :
    : The Edit_SetText(HWND hWnd, LPTSTR lpString) is similar to the SetWindowText function (actually it was #define). The Edit_SetText function works. Edit_SetText(hctl_type, TEXT("working")) will print out "working".
    :
    : My questions and problems are in regards to s1 and s2.
    : Is s1 = *(LPTSTR)(something); correct?
    : How do I get the unsigned short value out of (LPTSTR)(something)?
    : My goal is to compare two (LPTSTR)(something). Is there a function in does this, comparing two LPTSTR values?
    :
    : Thx in advance
    :

  • : Hi everyone, can someone help me with the following code
    :
    : Code:
    :
    : typedef unsigned short WCHAR;
    : typedef WCHAR *LPWSTR, *PWSTR;
    : typedef LPWSTR LPTSTR; //typedef lines are from winnt.h
    :
    : /*Global Variable*/
    : int trial = 0;
    :
    : function(.......)
    : {
    : WCHAR s1,s2;
    : HWND hctl_data, hctl_type;
    :
    : Edit_SetText(hctl_data, (LPTSTR)(something));
    : trial++;
    : s2 = s1;
    : s1 = *(LPTSTR)(something);
    :
    : if(trail > 2)
    : {
    : trial = 0;
    : if( s1 == s2)
    : {
    : Edit_SetText(hctl_type, TEXT("working");
    : }
    : }
    : }
    :
    : Code ends:
    :
    : The Edit_SetText(HWND hWnd, LPTSTR lpString) is similar to the SetWindowText function (actually it was #define). The Edit_SetText function works. Edit_SetText(hctl_type, TEXT("working")) will print out "working".
    :
    : My questions and problems are in regards to s1 and s2.
    : Is s1 = *(LPTSTR)(something); correct?
    : How do I get the unsigned short value out of (LPTSTR)(something)?
    : My goal is to compare two (LPTSTR)(something). Is there a function in does this, comparing two LPTSTR values?
    :
    : Thx in advance
    :

    This post really belongs to the C/C++ messageboards. Anyway, there should be a C function called strcmp or _strcmp or something. It will compare zero-terminated strings. The s1 and s2 variables you are using are single characters, rather than the strings you want them to be.
    What you need is making them LPTSTR variables and using the malloc() function to create space for the character strings. Then you can use I think it was the memcpy() function to copy the contents of one string to another.
    Anyway, this is all way too much to explain and it's been a while to me. Please repost this message on the appropriate board and you will get way more help.

    Best Regards,
    Richard

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories