Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2004.08.01;
Скачать: [xml.tar.bz2];

Вниз

Центр экрана!!!   Найти похожие ветки 

 
Шалунишка   (2004-06-20 14:52) [0]

Доюрый день!!! Подскажите ПОЖАЛУЙСТА как свою пргграммку расположить точно по середине экрана ?!! Зараннее благодарен...


 
Nick Denry ©   (2004-06-20 15:06) [1]

держи, противный... :))))



var desktop_rect : TRect;
{"заполнение переменных xPos,yPos,nWidth,nHeight}
 SystemParametersInfo(SPI_GETWORKAREA,0,@desktop_rect,0);
 
 nWidth:=271;
 nHeight:=271;
   
 xPos:=(desktop_rect.Right div 2)-(nWidth div 2);
 yPos:=(desktop_rect.Bottom div 2)-(Nheight div 2);
 { Создание главного окна}
 SCDWnd:=CreateWindowEx (
 0 ,                    //флаги расширенных стилей
 "SystemCD : Main",    //имя класса окна, данное при заполнении структуры SystemCD
 "SystemCD v.3.1",          //заголовок окна
 ws_popup , //флаги стилей окна
 {подробнdее о стилях см. после текста программы}
 xPos,               //горизонтальная позиция окна
 yPos,               //вертикальная позиция окна

 nWidth,             //ширина окна
 nHeight,            //высота окна
 0,                  //описатель родительского окна (parent) или окна-владельца (owner)
 0,                  //описатель меню окна (меню нет, нет и описателя)
 Hinstance,          //описатель приложения
 nil                 //address of window-creation data
 );
 {ShowWindow(SCDWnd,CmdShow); //Отображаем окно}


 
Шалунишка   (2004-06-20 15:18) [2]

А обзываться не зачем !!!


 
grom   (2004-06-20 15:47) [3]

a можно вот-так
procedure TForm1.FormShow(Sender: TObject);
begin
 Left:=trunc((Screen.Width-Width)/2);
 Top:=trunc((Screen.Height-Height)/2);
end;


 
VMcL ©   (2004-06-20 15:54) [4]

>>Шалунишка  (20.06.04 14:52)

Посередине видимой части экрана или посередине рабочей части экрана?


 
Шалунишка   (2004-06-20 16:23) [5]

>>VMcL

А если можно скажите пожалуйста так и так!!! Очень вас прошу.

>>grom
Спасибо

>> Nick Denry

Спасибо


 
Mim1 ©   (2004-06-20 19:02) [6]


> [3] grom   (20.06.04 15:47)

Надо заметить что приведенный вами код (обработчик события TForm и глобальный обьект screen) относится к vcl. А в vcl у формы есть специальное свойство отвечающее за распоодение окна в центре экрана, десктопа и т.д.


 
Nick Denry ©   (2004-06-20 20:01) [7]

2>Автор ветки

>А обзываться не зачем !!!

А я и не обзавылся... просто ник у тебя ... ну скажем странный :))

Не обижайся :))

По теме: если хочешь по центру экрана, а не рабочего стола, то еще нужно вычесь координаты панели задач (правда есть еще какой-то метод, но я не помню)..

SHAppBarMessage(ABM_QUERYPOS,wbs); - КООРДИНАТЫ ПАНЕЛИ ЗАДАЧ


 
grom   (2004-06-20 20:51) [8]

Mim1 ©   (20.06.04 19:02) [6]

mожно использовать и  poScreenCenter
результат будет тот же


 
YurikGL ©   (2004-06-20 21:21) [9]

Среди свойств формы есть position

poDesigned The form appears positioned on the screen and with the same height and width as it had at design time.
poDefault The form appears in a position on the screen and with a height and width determined by the operating system.
poDefaultPosOnly The form displays with the size you created it at design time, but the operating system chooses its position on the screen.
poDefaultSizeOnly The form appears in the position you left it at design time, but the operating system chooses its size.

poScreenCenter The form remains the size you left it at design time, but is positioned in the center of the screen. Note that in multi-monitor applications, this may result in a form that does not fall entirely on one monitor, because CLX does not include multi-monitor support.
poDesktopCenter The form remains the size you left it at design time, but is positioned in the center of the screen.
poMainFormCenter The form remains the size you left it at design time, but is positioned in the center of the application’s main form.  This position should only be used with secondary forms. If set for a main form, it acts like poScreenCenter.

poOwnerFormCenter The form remains the size you left it at design time, but is positioned in the center of the form specified by the Owner property. If the Owner property does not specify a form, this position acts like poMainFormCenter.

Выбирай нужную


 
Шалунишка   (2004-06-20 22:08) [10]

Спасибо всем всем всем!!! Для Nick"а Denry , Ну это я так, на самом деле я Dextor (Dextor-and.narod.ru, Dextor-and@yandex.ru);

                                          //P.S. Я еще вернусь!



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2004.08.01;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.044 c
8-1084456055
Ghost_tx
2004-05-13 17:47
2004.08.01
Описание формата JPEG


6-1086073893
Stop
2004-06-01 11:11
2004.08.01
idTCPServer, idTCPClient


14-1089977904
Prohodil Mimo
2004-07-16 15:38
2004.08.01
Просто мнение об отвлечённых темах.


14-1090037247
banderas
2004-07-17 08:07
2004.08.01
Молю о помощи !!!


1-1090248783
serg128
2004-07-19 18:53
2004.08.01
как в TTreeView получить родительский узел?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский