2009. 2. 16. 13:14

We were unable to locate this content in ko-kr.

Here is the same content in en-us.

SetWindowPos Function

Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.

Syntax

BOOL SetWindowPos(      
    HWND hWnd,     HWND hWndInsertAfter,     int X,     int Y,     int cx,     int cy,     UINT uFlags );

Parameters

hWnd
[in] A handle to the window.
hWndInsertAfter
[in] A handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values.
HWND_BOTTOM
Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows.
HWND_NOTOPMOST
Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
HWND_TOP
Places the window at the top of the Z order.
HWND_TOPMOST
Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
For more information about how this parameter is used, see the following Remarks section.
X
[in] Specifies the new position of the left side of the window, in client coordinates.
Y
[in] Specifies the new position of the top of the window, in client coordinates.
cx
[in] Specifies the new width of the window, in pixels.
cy
[in] Specifies the new height of the window, in pixels.
uFlags
[in] Specifies the window sizing and positioning flags. This parameter can be a combination of the following values.
SWP_ASYNCWINDOWPOS
If the calling thread and the thread that owns the window are attached to different input queues, the system posts the request to the thread that owns the window. This prevents the calling thread from blocking its execution while other threads process the request.
SWP_DEFERERASE
Prevents generation of the WM_SYNCPAINT message.
SWP_DRAWFRAME
Draws a frame (defined in the window's class description) around the window.
SWP_FRAMECHANGED
Applies new frame styles set using the SetWindowLong function. Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed.
SWP_HIDEWINDOW
Hides the window.
SWP_NOACTIVATE
Does not activate the window. If this flag is not set, the window is activated and moved to the top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter parameter).
SWP_NOCOPYBITS
Discards the entire contents of the client area. If this flag is not specified, the valid contents of the client area are saved and copied back into the client area after the window is sized or repositioned.
SWP_NOMOVE
Retains the current position (ignores X and Y parameters).
SWP_NOOWNERZORDER
Does not change the owner window's position in the Z order.
SWP_NOREDRAW
Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of the window being moved. When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.
SWP_NOREPOSITION
Same as the SWP_NOOWNERZORDER flag.
SWP_NOSENDCHANGING
Prevents the window from receiving the WM_WINDOWPOSCHANGING message.
SWP_NOSIZE
Retains the current size (ignores the cx and cy parameters).
SWP_NOZORDER
Retains the current Z order (ignores the hWndInsertAfter parameter).
SWP_SHOWWINDOW
Displays the window.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

As part of the Vista re-architecture, all services were moved off the interactive desktop into Session 0. hwnd and window manager operations are only effective inside a session and cross-session attempts to manipulate the hwnd will fail. For more information, see Session 0 Isolation.

If the SWP_SHOWWINDOW or SWP_HIDEWINDOW flag is set, the window cannot be moved or sized.

If you have changed certain window data using SetWindowLong, you must call SetWindowPos for the changes to take effect. Use the following combination for uFlags: SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED.

A window can be made a topmost window either by setting the hWndInsertAfter parameter to HWND_TOPMOST and ensuring that the SWP_NOZORDER flag is not set, or by setting a window's position in the Z order so that it is above any existing topmost windows. When a non-topmost window is made topmost, its owned windows are also made topmost. Its owners, however, are not changed.

If neither the SWP_NOACTIVATE nor SWP_NOZORDER flag is specified (that is, when the application requests that a window be simultaneously activated and its position in the Z order changed), the value specified in hWndInsertAfter is used only in the following circumstances.

  • Neither the HWND_TOPMOST nor HWND_NOTOPMOST flag is specified in hWndInsertAfter.
  • The window identified by hWnd is not the active window.

An application cannot activate an inactive window without also bringing it to the top of the Z order. Applications can change an activated window's position in the Z order without restrictions, or it can activate a window and then move it to the top of the topmost or non-topmost windows.

If a topmost window is repositioned to the bottom (HWND_BOTTOM) of the Z order or after any non-topmost window, it is no longer topmost. When a topmost window is made non-topmost, its owners and its owned windows are also made non-topmost windows.

A non-topmost window can own a topmost window, but the reverse cannot occur. Any window (for example, a dialog box) owned by a topmost window is itself made a topmost window, to ensure that all owned windows stay above their owner.

If an application is not in the foreground, and should be in the foreground, it must call the SetForegroundWindow function.

To use SetWindowPos to bring a window to the top, the process that owns the window must have SetForegroundWindow permission.

Example

For an example, see Initializing a Dialog Box.

Function Information

Minimum DLL Version user32.dll
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1
Unicode Implemented as Unicode version.

See Also


Posted by +깡통+
흐미~
원놈의 경고가 이렇게 많이 뜨나 했다..
sprintf 가 아니가 sprintf_s 를 사용해야 된다.  쩝.
아래는 VS2005 에서 사용해야하는 함수 목록들..

http://msdn2.microsoft.com/en-us/library/ms235384(VS.80).aspx


Run-Time Library Reference 
Deprecated CRT Functions 

Deprecated CRT functions and their recommended replacements.

Deprecated POSIX functions

The following POSIX names for functions are deprecated. In most cases, prepending an underscore character gives the standard equivalent name. Note that some functions have more secure versions ("_s" suffix).

You can also eliminate POSIX deprecation warnings by defining _CRT_NONSTDC_NO_DEPRECATE.

Deprecated function Replacement function

access

_access, _access_s

cabs

_cabs

cgets

_cgets, _cgets_s

chdir

_chdir

chmod

_chmod

chsize

_chsize, _chsize_s

close

_close

cprintf

_cprintf, _cprintf_s

cputs

_cputs

creat

_creat

cscanf

_cscanf, _cscanf_s

cwait

_cwait

dup

_dup

dup2

_dup2

ecvt

_ecvt, _ecvt_s

eof

_eof

execl

_execl

execle

_execle

execlp

_execlp

execlpe

_execlpe

execv

_execv

execve

_execve

execvp

_execvp

execvpe

_execvpe

fcloseall

_fcloseall

fcvt

_fcvt, _fcvt_s

fdopen

_fdopen

fgetchar

_fgetchar

filelength

_filelength

fileno

_fileno

flushall

_flushall

fputchar

_fputchar, _fputwchar

gcvt

_gcvt, _gcvt_s

getch

_getch

getche

_getche

getcwd

_getcwd, _wgetcwd

getpid

_getpid

getw

_getw

hypot

_hypot

inp

_inp

inpw

_inpw

isascii

__isascii

isatty

_isatty

iscsym

__iscsym

iscsymf

__iscsymf

itoa

_itoa, _itoa_s

j0

_j0

j1

_j1

jn

_jn

kbhit

_kbhit

lfind

_lfind, _lfind_s

locking

_locking

lsearch

_lsearch, _lsearch_s

lseek

_lseek

ltoa

_ltoa, _ltoa_s

memccpy

_memccpy

memicmp

_memicmp

mkdir

_mkdir

mktemp

_mktemp, _mktemp_s

open

_open

outp

_outp

outpw

_outpw

putch

_putch

putenv

_putenv, _putenv_s

putw

_putw

read

_read

rmdir

_rmdir

rmtmp

_rmtmp

setmode

_setmode

sopen

_sopen, _sopen_s

spawnl

_spawnl

spawnle

_spawnle

spawnlp

_spawnlp

spawnlpe

_spawnlpe

spawnv

_spawnv

spawnve

_spawnve

spawnvp

_spawnvp

spawnvpe

_spawnvpe

strcmpi

_stricmp

strdup

_strdup

stricmp

_stricmp

strlwr

_strlwr, _strlwr_s

strnicmp

_strnicmp

strnset

_strnset, _strnset_s

strrev

_strrev

strset

_strset, _strset_s

strupr

_strupr, _strupr_s

swab

_swab

tell

_tell

tempnam

_tempnam

toascii

__toascii

tzset

_tzset

ultoa

_ultoa, _ultoa_s

umask

_umask, _umask_s

ungetch

_ungetch

unlink

_unlink

wcsdup

_wcsdup

wcsicmp

_wcsicmp

wcsicoll

_wcsicoll

wcslwr

_wcslwr, _wcslwr_s

wcsnicmp

_wcsnicmp

wcsnset

_wcsnset, _wcsnset_s

wcsrev

_wcsrev

wcsset

_wcsset, _wcsset_s

wcsupr

_wcsupr, _wcsupr_s

write

_write

y0

_y0

y1

_y1

yn

_yn

Security-enhanced functions

The following functions should be avoided because a more secure version of the function should be used instead. For more information, see Security Enhancements in the CRT.

Deprecated function Security-enhanced replacement

_alloca

_malloca

asctime

asctime_s

_cgets, _cgetws

_cgets_s, _cgetws_s

_chsize

_chsize_s

_controlfp

_controlfp_s

_creat

_sopen_s

_cscanf

_cscanf_s

_cscanf_l

_cscanf_s_l

ctime

ctime_s

_ctime32

_ctime32_s

_ctime64

_ctime64_s

_cwscanf

_cwscanf_s

_cwscanf_l

_cwscanf_s_l

_ecvt

_ecvt_s

_fcvt

_fcvt_s

fopen

fopen_s

freopen

freopen_s

fscanf

fscanf_s

_fscanf_l

_fscanf_s_l

fwscanf

fwscanf_s

_fwscanf_l

_fwscanf_s_l

_gcvt

_gcvt_s

getenv

getenv_s

gets, _getws

gets_s, _getws_s

gmtime

_gmtime_s

_gmtime32

_gmtime32_s

_gmtime64

_gmtime64_s

_i64toa

_i64toa_s

_i64tow

_i64tow_s

_itoa

_itoa_s

_itow

_itow_s

localtime

_localtime_s

_localtime32

_localtime32_s

_localtime64

_localtime64_s

_ltoa, _ltow

_ltoa_s, _ltow_s

_mbccpy

_mbccpy_s

_mbccpy_l

_mbccpy_s_l

_mbscat

_mbscat_s

_mbscpy

_mbscpy_s

_mbslwr, _mbslwr_l

_mbslwr_s, _mbslwr_s_l

_mbsnbcat, _mbsnbcat_l

_mbsnbcat_s, _mbsnbcat_s_l

_mbsnbcpy, _mbsnbcpy_l

_mbsnbcpy_s, _mbsnbcpy_s_l

_mbsnbset

_mbsnbset_s

_mbsnbset_l

_mbsnbset_s_l

_mbsncat

_mbsncat_s

_mbsncat_l

_mbsncat_s_l

_mbsncpy

_mbsncpy_s

_mbsncpy_l

_mbsncpy_s_l

_mbsnset

_mbsnset_s

_mbsnset_l

_mbsnset_s_l

mbsrtowcs

mbsrtowcs_s

_mbsset

_mbsset_s

_mbsset_l

_mbsset_s_l

_mbstok

_mbstok_s

_mbstok_l

_mbstok_s_l

mbstowcs, _mbstowcs_l

mbstowcs_s, _mbstowcs_s_l

_mbsupr, _mbsupr_l

_mbsupr_s, _mbsupr_s_l

memcpy

memcpy_s

memmove

memmove_s

_mktemp

_mktemp_s

_open

_sopen_s

scanf

scanf_s

_scanf_l

_scanf_s_l

_searchenv

_searchenv_s

setbuf

setvbuf

_snprintf

_snprintf_s

_snprintf_l

_snprintf_s_l

_snscanf

_snscanf_s

_snscanf_l

_snscanf_s_l

_snwprintf

_snwprintf_s

_snwprintf_l

_snwprintf_s_l

_snwscanf

_snwscanf_s

_snwscanf_l

_snwscanf_s_l

_sopen

_sopen_s

_splitpath

_splitpath_s

sprintf

sprintf_s

_sprintf_l

_sprintf_s_l

sscanf

sscanf_s

_sscanf_l

_sscanf_s_l

strcat

strcat_s

strcpy

strcpy_s

_strdate

_strdate_s

strerror, _strerror

strerror_s, _strerror_s

_strlwr, _strlwr_l

_strlwr_s, _strlwr_s_l

strncat, _strncat_l

strncat_s, _strncat_s_l

strncpy, _strncpy_l

strncpy_s, _strncpy_s_l

_strnset

_strnset_s

_strnset_l

_strnset_s_l

_strset

_strset_s

_strset_l

_strset_s_l

_strtime

_strtime_s

strtok

strtok_s

_strtok_l

_strtok_s_l

_strupr, _strupr_l

_strupr_s, _strupr_s_l

swprintf

swprintf_s

_swprintf_l

_swprintf_s_l

swscanf

swscanf_s

_swscanf_l

_swscanf_s_l

tmpfile

tmpfile_s

_ui64toa, _ui64tow

_ui64toa_s, _ui64tow_s

_ultoa, _ultow

_ultoa_s, _ultow_s

_umask

_umask_s

vsnprintf, _vsnprintf, _vsnprintf_l, _vsnwprintf, _vsnwprintf_l

vsnprintf_s, _vsnprintf_s, _vsnprintf_s_l, _vsnwprintf_s, _vsnwprintf_s_l

vsprintf, _vsprintf_l, vswprintf, _vswprintf_l, __vswprintf_l

vsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l

_wasctime

_wasctime_s

_wcreat

_wsopen_s

wcrtomb

wcrtomb_s

wcscat

wcscat_s

wcscpy

wcscpy_s

_wcserror, __wcserror

_wcserror_s, __wcserror_s

_wcslwr, _wcslwr_l

_wcslwr_s, _wcslwr_s_l

wcsncat, wcsncat_l

wcsncat_s, _wcsncat_s_l

_wcsncpy, _wcsncpy_l

wcsncpy_s, _wcsncpy_s_l

_wcsnset, _wcsnset_l

_wcsnset_s, _wcsnset_s_l

wcsrtombs

wcsrtombs_s

_wcsset, _wcsset_l

_wcsset_s_wcsset_s_l

wcstok, _wcstok_l

wcstok_s, _wcstok_s_l

wcstombs, _wcstombs_l

wcstombs_s, _wcstombs_s_l

_wcsupr_l, _wcsupr

_wcsupr_s, _wcsupr_s_l

_wctime, _wctime32, _wctime64

_wctime_s, _wctime32_s, _wctime64_s

wctomb, _wctomb_l

wctomb_s, _wctomb_s_l

_wfopen

_wfopen_s

_wfreopen

_wfreopen_s

_wgetenv

_wgetenv_s

wmemcpy

wmemcpy_s

wmemmove

wmemmove_s

_wmktemp

_wmktemp_s

_wopen

_wsopen_s

_wscanf, _wscanf_l

_wscanf_s, _wscanf_s_l

_wsearchenv

_wsearchenv_s

_wsopen

_wsopen_s

_wsplitpath

_wsplitpath_s

_wstrdate

_wstrdate_s

_wstrtime

_wstrtime_s

Functions with Secure Template Overloads

Posted by +깡통+
와 장장 이틀동안 검색과 삽질의 결과물 입니다 ㅠㅠ..

누가보면 미련하기 짝이 없겠죠?

이렇게 얻은 수확물은 평생 머리속에서 빠져 나가지 않을 것입니다.

아래 구문을 잘 봐야 합니다.
SDK 에서 설명하기로는 m_Player 의 .GetCurrentMedia() 로 연결하라고 되어 있습니다.
이렇게하면 GetDuration() 에 불량한 값이 나옵니다.

double nDur = m_Player.GetControls().GetCurrentItem().GetDuration();

이렇게 시도하니 잘 됩니다.
하지만 프로그램 종료시 디버그 창을 속출합니다.


BOOL CWMP11SampleDlg::OnInitDialog()
{
 CDialog::OnInitDialog();
 ...
 m_clsWMPSettings = m_ctrWMP.GetSettings();
 m_clsWMPControl = m_ctrWMP.GetControls();
 m_clsWMPMedia = m_ctrWMP.GetCurrentMedia();  // 이렇게 하시면 낭패 입니다.
 m_clsWMPMedia = m_ctrWMPControl.GetCurrentItem();  // 이렇게 하셔도 낭패 입니다.
 ...
SetTimer(1, 1000, NULL);
}

void CWMP11SampleDlg::OpenStateChangeOcxWmp(long NewState)
{
 // TODO: 여기에 메시지 처리기 코드를 추가합니다.
 switch(NewState)
 {
 case 13: //  MediaOpen
  m_clsWMPMedia = m_clsWMPControl.GetCurrentItem(); // 이쯤에서 받아 들이십시오.  -_- 휴~
  m_ctlTime.SetRange(0, (int)m_clsWMPMedia.GetDuration(), TRUE);
  m_ctlTime.SetPos(0);
  break;
 }
 pEdit->SetWindowTextA(strTemp);
}


void CWMP11SampleDlg::OnTimer(UINT_PTR nIDEvent)
{
 // TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
 switch(nIDEvent)
 {
 case 1:
  m_ctlTime.SetPos((int)m_clsWMPControl.GetCurrentPosition());
 }
 CDialog::OnTimer(nIDEvent);
}
Posted by +깡통+