Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Window.cpp « Windows - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 61e005c8b608f8d68f575492610d89f9d0589904 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Windows/Window.cpp

#include "StdAfx.h"

#include "Windows/Window.h"
#ifndef _UNICODE
#include "Common/StringConvert.h"
#endif

namespace NWindows {

#ifndef _UNICODE
bool CWindow::SetText(LPCWSTR s)
{ 
  if (::SetWindowTextW(_window, s))
    return true;
  if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
    return false;
  return SetText(UnicodeStringToMultiByte(s));
}
#endif

bool CWindow::GetText(CSysString &s)
{
  s.Empty();
  int length = GetTextLength();
  if (length == 0)
    return (::GetLastError() == ERROR_SUCCESS);
  length = GetText(s.GetBuffer(length), length + 1);
  s.ReleaseBuffer();
  if (length == 0)
    return (::GetLastError() != ERROR_SUCCESS);
  return true;
}

#ifndef _UNICODE
bool CWindow::GetText(UString &s)
{
  s.Empty();
  int length = GetWindowTextLengthW(_window);
  if (length == 0)
  {
    UINT lastError = ::GetLastError();
    if (lastError == ERROR_SUCCESS)
      return true;
    if (lastError != ERROR_CALL_NOT_IMPLEMENTED)
      return false;
    CSysString sysString;
    bool result = GetText(sysString);
    s = GetUnicodeString(sysString);
    return result;
  }
  length = GetWindowTextW(_window, s.GetBuffer(length), length + 1);
  s.ReleaseBuffer();
  if (length == 0)
    return (::GetLastError() == ERROR_SUCCESS);
  return true;
}
#endif
  
/*
bool CWindow::ModifyStyleBase(int styleOffset,
  DWORD remove, DWORD add, UINT flags)
{
  DWORD style = GetWindowLong(styleOffset);
  DWORD newStyle = (style & ~remove) | add;
  if (style == newStyle)
    return false; // it is not good 

  SetWindowLong(styleOffset, newStyle);
  if (flags != 0)
  {
    ::SetWindowPos(_window, NULL, 0, 0, 0, 0,
      SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | flags);
  }
  return TRUE;
}
*/

}