ãáß ÇáÓí ÔÇÑÈ
03-11-2009, 12:48 PM
ÊÍÏí ÊÍÏí ÊÍÏí ............
ÇáÓÄÇá ÇáÃæá .
ßíÝ ããßä Îáí combo box ÊßÊÈ ÈÎÇÕíÉ ÊæÓíØ ÇáäÕ
íÚäí Îáí ÇáßÊÇÈÉ æÓØ ÇáÚäÕÑ æáíÓ ãä ÇáíÓÇÑ Ãæ Çáíãíä
ãáÇÍÙÉ : ÇáãåáÉ íæãíä
:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D
Thaer_yeah
03-11-2009, 01:29 PM
100 åáÇ Ýíß æÈßá ãíä ÈíÍÈ ÇáÊÍÏí
ÈÇáäÓÈÉ ááÓÄÇá
åÐå åí ÇáÏÇáÉ ÇáãÓÄáÉ Úä ßæÏ ÇáÊæÓíØ
æ ÇáÔÑÍ ãæÌæÏ Öãä ÇáßæÏ !!:)
Þã ÈÚãá æÍÏÉ äãØíÉ ÌÏíÏå æÞã ÈäÓÎ åÐå ÇáßæÏ ÈÏÇÎáåÇ
ÇÐÇ áã íßä åÐÇ ÇáÊÚÈíÑ ãæÌæÏ áÏíß ÝÞã ÈæÖÚå Ýí ÈÏÇíÉ ÇáßæÏ
option explicit
ßæÏ sql
private type rect
left as long
top as long
right as long
bottom as long
end type
private const lf_facesize = 32
private type logfont
lfheight as long
lfwidth as long
lfescapement as long
lforientation as long
lfweight as long
lfitalic as byte
lfunderline as byte
lfstrikeout as byte
lfcharset as byte
lfoutprecision as byte
lfclipprecision as byte
lfquality as byte
lfpitchandfamily as byte
lffacename as string * lf_facesize
end type
private type textmetric
tmheight as long
tmascent as long
tmdescent as long
tminternalleading as long
tmexternalleading as long
tmavecharwidth as long
tmmaxcharwidth as long
tmweight as long
tmoverhang as long
tmdigitizedaspectx as long
tmdigitizedaspecty as long
tmfirstchar as byte
tmlastchar as byte
tmdefaultchar as byte
tmbreakchar as byte
tmitalic as byte
tmunderlined as byte
tmstruckout as byte
tmpitchandfamily as byte
tmcharset as byte
end type
private declare function gettextmetrics lib "gdi32" alias "gettextmetricsa" _
(byval hdc as long, lpmetrics as textmetric) as long
private declare function apicreatefontindirect lib "gdi32" alias _
"createfontindirecta" (lplogfont as logfont) as long
private declare function apiselectobject lib "gdi32" alias "selectobject" _
(byval hdc as long, _
byval hobject as long) as long
private declare function apideleteobject lib "gdi32" _
alias "deleteobject" (byval hobject as long) as long
private declare function apigetdevicecaps lib "gdi32" alias "getdevicecaps" _
(byval hdc as long, byval nindex as long) as long
private declare function apimuldiv lib "kernel32" alias "muldiv" _
(byval nnumber as long, _
byval nnumerator as long, byval ndenominator as long) as long
private declare function apigetdc lib "user32" _
alias "getdc" (byval hwnd as long) as long
private declare function apireleasedc lib "user32" _
alias "releasedc" (byval hwnd as long, _
byval hdc as long) as long
private declare function apidrawtext lib "user32" alias "drawtexta" _
(byval hdc as long, byval lpstr as string, byval ncount as long, _
lprect as rect, byval wformat as long) as long
private declare function createdcbynum lib "gdi32" alias "createdca" _
(byval lpdrivername as string, byval lpdevicename as string, _
byval lpoutput as long, byval lpinitdata as long) as long 'devmode) as long
private declare function apideletedc lib "gdi32" _
alias "deletedc" (byval hdc as long) as long
declare function getprofilestring lib "kernel32" _
alias "getprofilestringa" _
(byval lpappname as string, _
byval lpkeyname as string, _
byval lpdefault as string, _
byval lpreturnedstring as string, _
byval nsize as long) as long
' ãÍÊæíÇÊ ÇáßæÏ
private const twipsperinch = 1440
' íÓÊÎÏã áÓÄÇá ÇáäÙÇã Ýí ßá ÈßÓá Úáì Çáã꾄 ÇáÓíäí æÇáÕÇÏí
private const logpixelsy = 90
private const logpixelsx = 88
' íÊã åäÇ ãÚÇáÌÉ ÇáäÕæÕ
private const dt_top = &h0
private const dt_left = &h0
private const dt_calcrect = &h400
private const dt_wordbreak = &h10
private const dt_externalleading = &h200
private const dt_editcontrol = &h2000&
private const dt_noclip = &h100
' ÎÇÕ ÈÇáÎØæØ
private const out_default_precis = 0
private const out_string_precis = 1
private const out_character_precis = 2
private const out_stroke_precis = 3
private const out_tt_precis = 4
private const out_device_precis = 5
private const out_raster_precis = 6
private const out_tt_only_precis = 7
private const out_outline_precis = 8
private const clip_default_precis = 0
private const clip_character_precis = 1
private const clip_stroke_precis = 2
private const clip_mask = &hf
private const clip_lh_angles = 16
private const clip_tt_always = 32
private const clip_embedded = 128
private const default_quality = 0
private const draft_quality = 1
private const proof_quality = 2
private const default_pitch = 0
private const fixed_pitch = 1
private const variable_pitch = 2
private const ansi_charset = 0
private const default_charset = 1
private const symbol_charset = 2
private const shiftjis_charset = 128
private const hangeul_charset = 129
private const chinesebig5_charset = 136
private const oem_charset = 255
'
public function ftextheight(ctl as control, _
optional byval stext as string = "", _
optional heighttwips as long = 0, optional widthtwips as long = 0, _
optional totallines as long = 0, _
optional twipsperpixel as long = 0) as long on error resume next
' íÊã åäÇ ÇÓÊÏÇÚÇÁ ÇáÏÇáÉ áãÚÇáÌÉ ÇÑÊÝÇÚ ÇáäÕ
' ÇÐÇ ßÇä ÇÑÊÝÇÚ ÇáäÕ ÕÍíÍÇ Ýí ÚäÕÑ ÇáÊÍßã ÇÐä ÊÊã ÇáãÚÇáÌÉ ááÇÑÊÝÇÚ
ftextheight = ftextwidthorheight(ctl, true, _
stext, heighttwips, widthtwips, totallines, twipsperpixel)
end function
public function ftextwidth(ctl as control, _
optional byval stext as string = "", _
optional heighttwips as long = 0, optional widthtwips as long = 0, _
optional totallines as long = 0, _
optional twipsperpixel as long = 0) as long on error resume next
' ÇÐÇ ßÇä ÇÑÊÝÇÚ ÇáäÕ ÛíÑ ÕÍíÍ ÝÊÊã ÇáãÚÇáÌÉ ááÚÑÖ
' íÊã åäÇ ÇÓÊÏÚÇÁ ÇáÏÇáÉ áãÚÇáÌÉ ÚÑÖ ÇáäÕ
ftextwidth = ftextwidthorheight(ctl, false, _
stext, heighttwips, widthtwips, totallines, twipsperpixel)
end function
public function ftextwidthorheight(ctl as control, byval blwh as boolean, _
optional byval stext as string = "", _
optional heighttwips as long = 0, optional widthtwips as long = 0, _
optional totallines as long = 0, _
optional twipsperpixel as long = 0) as long
dim srect as rect
dim hdc as long
dim lngdpi as long
dim newfont as long
dim oldfont as long
dim lngret as long
dim myfont as logfont
dim tm as textmetric
dim lnglinespacing as long
dim numlines as long
dim strname as string
dim sngtemp1 as single
dim sngtemp2 as single on error goto err_handler
if typeof ctl.parent is access.report then
strname = getdefaultprintersname
hdc = createdcbynum("winspool", strname, 0&, 0&)
if hdc = 0 then
err.raise vbobjecterror + 255, "ftextwidthorheight", "cannot create printer dc"
end if
else
hdc = apigetdc(0&)
end if
if len(stext & vbnullstring) = 0 then
select case ctl.controltype
case actextbox
stext = nz(ctl.value, vbnullstring)
case aclabel, accommandbutton
stext = nz(ctl.caption, vbnullstring)
case aclistbox
stext = nz(ctl.itemdata(0), vbnullstring)
case else
ftextwidthorheight = 0
exit function
end select
end if
if blwh then
lngdpi = apigetdevicecaps(hdc, logpixelsy)
else
lngdpi = apigetdevicecaps(hdc, logpixelsx)
end if
twipsperpixel = twipsperinch / lngdpi
with ctl
myfont.lfclipprecision = clip_lh_angles
myfont.lfoutprecision = 0
myfont.lfescapement = 0
myfont.lffacename = .fontname & chr$(0)
myfont.lfweight = .fontweight
myfont.lfitalic = .fontitalic
myfont.lfunderline = .fontunderline
myfont.lfheight = (.fontsize / 72) * -lngdpi
newfont = apicreatefontindirect(myfont)
end with
if newfont = 0 then
err.raise vbobjecterror + 256, "ftextwidthorheight", "cannot create font"
end if
oldfont = apiselectobject(hdc, newfont)
with srect
.left = 0
.top = 0
.bottom = 0
if blwh then
.right = (ctl.width / (twipsperinch / lngdpi)) - 10
else
.right = 32000
end if
lngret = apidrawtext(hdc, stext, -1, srect, dt_calcrect or dt_top or _
dt_left or dt_wordbreak or dt_noclip)
lngret = gettextmetrics(hdc, tm)
lngret = apiselectobject(hdc, oldfont)
apideleteobject (newfont)
if typeof ctl.parent is access.report then
lngret = apideletedc(hdc)
else
lngret = apireleasedc(0&, hdc)
end if
totallines = .bottom / (tm.tmheight + tm.tmexternalleading)
numlines = totallines
.bottom = (.bottom) * (twipsperinch / lngdpi)
heighttwips = .bottom
widthtwips = .right * (twipsperinch / lngdpi)
if blwh then
ftextwidthorheight = heighttwips
else
ftextwidthorheight = widthtwips
end if
end with
exit_ok:
Exit function
err_handler:
Err.raise err.source, err.number, err.description
resume exit_ok
end function
function getdefaultprintersname() as string
' åäÇ íÊã ÇÓÊÏÚÇÁ ÇáØÇÈÚÉ ÇáÇÝÊÑÇÖíÉ
'æÌÚáåÇ ÊÞÈá ÇáÞíã ÇáÌÏíÏå ÇáãÚÏáÉ Ýí ÇáÊÞÑíÑ
' ÈÏæä åÐÇ ÇáßæÏ ÓíØÈÚ ÇáÊÞÑíÑ ÈÏæä ÊæÓíØ ááÍÞæá
dim success as long
dim nsize as long
dim lpkeyname as string
dim ret as string
dim posdriver
ret = space$(8102)
nsize = len(ret)
success = getprofilestring("windows", "device", "", ret, nsize)
posdriver = instr(ret, ",")
getdefaultprintersname = left$(ret, posdriver - 1)
end function
public function screentwipsperpixel() as long
dim hdc as long
dim lngret as long
' Ýí åÐÇ ÇáßæÏ Êã ãÚÇáÌÉ ÈÚÖ ÇÎØÇÁ ÇáØÇÈÚÇÊ
' ÇáÊí ÈÌÈ Çä ÊØÈÚ ãÇ åæ ãæÌæÏ Úáì ÇáÔÇÔÉ æÈäÝÓ ÇáÊäÓíÞ
hdc = apigetdc(0&)
screentwipsperpixel = twipsperinch / apigetdevicecaps(hdc, logpixelsy)
'åäÇ ßæÏ ÇáÊÍÑíÑ ãä ÇáßæÏ ÇáÓÇÈÞ
lngret = apireleasedc(0&, hdc)
end function
A_Alakkad
03-11-2009, 01:49 PM
ÇáÓáÇã Úáíßã .
ÈÇáäÓÈÉ ááÓÄÇá : åæ ÈÇáÜÓí ÔÇÑÈ æáÇ ÈÇáÝíÌæÇá ÈíÓß ¿¿
ÃãÇ ÇáÌæÇÈ ÝÇÇáÙÇåÑ Ãäæ åæ ÌæÇÈ ÈáÛÉ ÇáÝíÌæÇá ÈíÓß .
ÝÃÑÌæ ÇáÊæÖíÍ ....
ãáß ÇáÓí ÔÇÑÈ
03-12-2009, 11:18 AM
ÃæáÇ : ÔßÑÇ ßËíÑ Úáì ÞÈæá ÇáÊÍÏí .
ËÇäíÇ : ÇáÍá ãØáæÈ ÈÇÓÊÎÏÇã ÃÏæÇÊ ÇááÛÉ Ãí ÚÏã ÇááÌæÁ Åáì ÊæÇÈÚ api Ãæ mfc æãÇ ÔÇÈå .
ËÇáËÇ : æ ÇáÃåã ÇáÍá ãØáæÈ Óí ÔÇÑÈ ÈÏÑÌÉ ÇáÃæáì ÈÓÈÈ ÏÑÇíÉ ØáÇÈ ÇáãÚåÏ ÈåÐå ÇááÛÉ .
Úáì ÝßÑÉ ÇáÍá ÇÈÓØ ÈßËíÑ ãä ÇáÍá ÇáÓÇÈÞ áÇ íÊÌÇæÒ ÇáÚÔÑÉ ÇÓØÑ .
Thaer_yeah
03-12-2009, 12:45 PM
íãßä ÈÊÞÕÏ åí :
-Alignment ÎÇÕíÉ ÇáãÍÇÐÇÊ ÇáäÕ Ýí ÇáÇÏÇÊ æíÃÎÐ ÇáÞíã ÇáÊÇáíÉ :
ßæÏ:
Label1.Alignment = 0 ' ÇíÓÑ
Label1.Alignment = 1 ' Çíãä
Label1.Alignment = 2 'æÓØ
ãáß ÇáÓí ÔÇÑÈ
03-13-2009, 12:50 AM
ÔæÝ ÇáÈÑäÇãÌ (http://www.4shared.com/file/92642853/ba97f166/ComboBoxTest.html)
ãáß ÇáÓí ÔÇÑÈ
03-14-2009, 08:44 AM
Ôæ ãÇÝí ÑÌÇá ÊÊÍÏì ãÚÞæá
Úáì ÝßÑÉ ÇäÇ ÈÚÑÝ ÇáÍá ÈÓ áÇíãßä ÇÞæáå ÍÊì ÔæÝ ÈÑäÇãÌ ÔÛÇá Úä ÇáÝßÑÉ
ÊãÇã
ÓáÇã
Úáì ÝßÑÉ ãÓÊæì ÇáÊÏÑíÓ Ýí ÇáãÚåÏ ßÊíÑ ãäíÍ ÈÓ æíä ÇáÇÈÏÇÚ ãÇÈÚÑÝ
Executioner
04-29-2009, 02:28 PM
ÇáÓáÇã Úáíßã
ÛÑíÈ ãÇÝí åíß ÎÇÕíÉ!! :confused:
ãÚäÇåÇ Ýí Åäø ÈÇáãæÖæÚ ;)
ÈÙä ÇáÔÛáÉ ÝíåÇ ÚãáíÉ æÑÇËÉ Úáì Override ãÇ åíß¿ :rolleyes:
ÕÍíÍ ÃäÇ ÈÚÑÝß Ôí ¿¿¿¿¿