EM_GETLINE And Unicode?

This is a discussion on EM_GETLINE And Unicode? within the Windows Programming forums, part of the Platform Specific Boards category; does EM_GETLINE support unicode? if not then is there something simmiliar that supports unicode and if so how come unicode ...

  1. #1
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    EM_GETLINE And Unicode?

    does EM_GETLINE support unicode? if not then is there something simmiliar that supports unicode and if so how come unicode chars are showing as ?'s

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    >> does EM_GETLINE support unicode? <<

    Yes.

    >> if so how come unicode chars are showing as ?'s <<

    Firstly, EM_GETLINE does not null terminate the buffer so you have to take care of this. It depends where you are outputting the unicode text after you have retrieved it with EM_GETLINE and font support. In my experience, the console and MessageBox, at least with the default font settings, are not able to render many unicode characters. Edit controls and internet browsers seem to do a much better job.

  3. #3
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    hmm

    hmmm it should be working its reading from a rtf control and printing to a rtf control and
    #define UNICODE
    #define _UNICODE is in there :S

    heres the code im using

    Code:
    	TCHAR JoinText[128] = {0};
    	TCHAR RBN[50] = {0};
    	TCHAR pbMsg[50] = {0};
    	TCHAR teststring[128] = {0};
    	int npt = 0;
    	int NumLines;
    
    
    	NumLines = SendMessage(hwndOut , EM_GETLINECOUNT , (WPARAM)0 , (LPARAM)0);
    	*((LPINT)JoinText) = sizeof(JoinText);
    	npt = SendMessage(hwndOut, EM_GETLINE, (WPARAM)lines-2, (LPARAM)JoinText);
    	JoinText[npt] = 0;
    	_stprintf(teststring , _T("%s") , JoinText);
    	SendMessage(HH , WM_SETTEXT , (WPARAM)0 , (LPARAM)teststring);
    and it shows ?s for the unicode

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    This line:
    Code:
    	*((LPINT)JoinText) = sizeof(JoinText);
    should be:
    Code:
    	*((LPWORD)JoinText) = sizeof(JoinText) / sizeof(TCHAR); // or use ARRAYSIZE macro
    but that isn't causing your problem.

    Are you sure that UNICODE and _UNICODE are #defined above all #includes?

    You can test if unicode is in effect:
    Code:
    if (sizeof(_T("x")) != 4 || sizeof(TEXT("x")) != 4)
          MessageBox(NULL, _T("NO Unicode!"), NULL, 0);
    else
          MessageBox(NULL, _T("YES Unicode!"), NULL, 0);

  5. #5
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    its still not working , doing the same thing as before

  6. #6
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    also yeh unicode is defined above the #includes.

  7. #7
    rHm
    rHm is offline
    Registered User
    Join Date
    Jul 2004
    Posts
    4
    Win95, 98 and ME do not support UNICODE in the standard system libraries. NT4 an later is internally based on UNICODE. Maybe you are testing on 9x?

  8. #8
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    Code:
    	TCHAR JoinText[128] = {0};
    	TCHAR PBN[50] = {0};
    	TCHAR pbMsg[50] = {0};
    	TCHAR PBL[128] = {0};
    
    
    
    
    	FILE *pbf;
    
    	int npt = 0;
    
    	int NumLines;
    
    	NumLines = SendMessage(hwndOut , EM_GETLINECOUNT , (WPARAM)0 , (LPARAM)0);
    	*((LPWORD)JoinText) = sizeof(JoinText) / sizeof(TCHAR); // or use ARRAYSIZE macro
    	npt = SendMessage(hwndOut, EM_GETLINE, (WPARAM)lines-2, (LPARAM)JoinText);
    	JoinText[npt] = 0;
    thats on windowsXP the unicode is defined above all includes its at the very top.

    it shows unicode chars as question marks , ive tried showing it in a messagebox and tried sending it to a RTF control which works with some other parts of the program(sending unicode to a rtf control).
    i think its something with the way its reading it?

  9. #9
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    any one out there this is really important and i cant work it out

  10. #10
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    The behaviour seems most unusual. The only thing I can suggest is that you remove the #defines for UNICODE and _UNICODE from any files you've placed them in and pass the defines directly to your compiler itself. This will ensure that they are defined for your whole project. Your compiler documentation should have details on the correct syntax - for example, for gcc:
    Code:
    -DUNICODE -D_UNICODE
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  11. #11
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    didnt make any difference its still the same

  12. #12
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    im using lcc-win32 for it and i thought it could be the problem so i tried it in dev-c++ and its still the same

  13. #13
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Could you zip up and attach your dev-cpp project and/or your lcc-win32 code + makefile (if they're not too large) so that we can maybe take a closer look at it?
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  14. #14
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    Code:
    #define UNICODE
    #define _UNICODE
    #include <windows.h>
    #include <tchar.h>
    #define ID_TIMER 1
    VOID CALLBACK PermBan(HWND, UINT, UINT, DWORD);
    LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
    
      TCHAR szClassName[] = _T("Class Name");
      HWND hwnd , HackedHandle;
      MSG messages;
      WNDCLASSEX wincl;
      POINT pt;
    
    // Start WinMain() ...
    
    int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) {
    
    
      wincl.hInstance = hThisInstance;
      wincl.lpszClassName = szClassName;
      wincl.lpfnWndProc = WindowProcedure;
      wincl.style = CS_DBLCLKS;
      wincl.cbSize = sizeof(WNDCLASSEX);
      wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
      wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
      wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
      wincl.lpszMenuName = NULL;
      wincl.cbClsExtra = 0;
      wincl.cbWndExtra = 0;
      wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
    
    if(!RegisterClassEx(&wincl)) return 0;
    
    hwnd = CreateWindowEx(0, szClassName, _T("Title"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, HWND_DESKTOP, NULL, hThisInstance, NULL);
    
    ShowWindow(hwnd, SW_SHOW);
    UpdateWindow(hwnd);
    
    while(GetMessage(&messages, NULL, 0, 0))
    {
      TranslateMessage(&messages);
      DispatchMessage(&messages);
    }
    
      return messages.wParam;
    }
    
    // Start WindowProcedure() ...
    
    LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
    
    switch (message)
    {
    
      case WM_DESTROY:
        PostQuitMessage(0);
      break;
    
      case WM_COMMAND:
        // Processing ...
      break;
      
      case WM_CREATE:
      
      	MessageBox(0 , _T("") , _T("") , 0);
      	GetCursorPos(&pt);
      	HackedHandle = WindowFromPoint(pt);
      	SetTimer(hwnd , ID_TIMER , 1000 , PermBan);
    
    
      default:
        return DefWindowProc(hwnd, message, wParam, lParam);
    
    }
    
    return 0;
    }
    
    
    VOID CALLBACK PermBan(HWND hwnd , UINT message , UINT uTimerID , DWORD dwTime)
    {
    
    	TCHAR JoinText[128] = {0};
    	TCHAR PBN[50] = {0};
    	TCHAR pbMsg[50] = {0};
    	TCHAR PBL[128] = {0};
    	TCHAR PBC128];
    
    	int npt = 0;
    
    	int NumLines;
    
    	NumLines = SendMessage(HackedHandle , EM_GETLINECOUNT , (WPARAM)0 , (LPARAM)0);
    	*((LPWORD)JoinText) = sizeof(JoinText) / sizeof(TCHAR);
    	npt = SendMessage(HackedHandle, EM_GETLINE, (WPARAM)NumLines-2, (LPARAM)JoinText);
    	JoinText[npt] = 0;
    
    	if (_tcsstr(JoinText,_T("TesT")) && (!_tcsstr(JoinText,_T(">")))){
    		MessageBox(0 , JoinText , _T("test") , 0);
    
    	}
    }
    thats the dev c++ code,
    Last edited by Rare177; 07-26-2004 at 05:34 AM.

  15. #15
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    any one out there i havnt got it working yet

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21