الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

XP Styles in VB6

مغلق
بدأه msayed2004 في 9 مارس 2007 · 20 رد · 6,783 مشاهدة · في قسم الدروس والمواضيع الهامة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بعد استئذان الأخ HnHn هقدم لكم درس بس بالأنجليزية و يارب يكون سهل :

This tutorial is about enabling XP styles for the VB standard controls only, also will not work for the Frame control

Since VB6 is an old language (in comparison with last windows version) it does not support drawing the XP styles on its controls and because Microsoft no more support VB6 we should not except a direct solution for this issue.

Steve McMahon كتب:
The New XP Styles

The Windows XP Visual Styles are provided by ComCtl32.dll version 6 or later. (In fact, anyone who is as old as me and remembers back to Visual Basic 3 may find this familiar, since the exciting 3D control look which was provided with Windows 95 was also implemented in the same way). Note that unlike previous versions of this DLL, version 6 is not redistributable - which sadly means you can only use the visual styles on an operating system that has this version installed. At the time of writing this means XP only.

ComCtl32 does not apply the latest styles to the client area of an application by default. In order to enable it, you need to ensure that your application is linked to ComCtl32.dll (by calling the ComCtl InitCommonControls API call) and then you need to provide a Manifest which specifies that the new version of the control styles should be used.

To show XP styles in our VB6 products we need to do 3 steps :

1-Including a special manifest file with our project.

2-Initialize the common controls by calling the InitCommonControlsEx API (supported by comctl32.dll).

3-Protect our application from possible GPF (General Protection Fault) while closing the application.

1-The manifest file should be in the same directory (folder) of our application this file should be named as follow :

If our application name (including the extension) is Test.exe the manifest file should be Test.exe.manifest.

Contents of the manifest file :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

   <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

   <assemblyIdentity

	   version="1.0.0.0"

	   processorArchitecture="X86"

	   name="*"

	   type="win32"

   />

   <description>XP Styles</description>

   <dependency>

	   <dependentAssembly>

		   <assemblyIdentity

			   type="win32"

			   name="Microsoft.Windows.Common-Controls"

			   version="6.0.0.0"

			   processorArchitecture="X86"

			   publicKeyToken="6595b64144ccf1df"

			   language="*"

		   />

	   </dependentAssembly>

   </dependency>

   </assembly>

2-Initialize the common controls : do this once at the start of your application :

'APIs declarations:

   Private Type tagInitCommonControlsEx

	  lngSize As Long

	  lngICC As Long

   End Type

   Private Declare Function InitCommonControlsEx Lib "comctl32.dll" (iccex As tagInitCommonControlsEx) As Boolean

   Private Const ICC_USEREX_CLASSES = &H200

Now we just need to call the following function :

Private Function InitCommonControlsVB() As Boolean

	  On Error Resume Next

	  Dim iccex As tagInitCommonControlsEx



	  With iccex

		  .lngSize = LenB(iccex)

		  .lngICC = ICC_USEREX_CLASSES

	  End With



	  InitCommonControlsEx iccex

	  InitCommonControlsVB = (Err.Number = 0)

	  On Error GoTo 0

   End Function

Warning : Including the manifest file without initializing the common controls will result in the following error :

Error.jpg

3-After using the previous method to give your application XP styles it mau crash when you close it (GPF) hence we should prevent this , this can be done by calling the SetErrorMode API (supported by kernel32.dll) & set the mode to SEM_NOGPFAULTERRORBOX

'APIs declarations:

   Public Const SEM_NOGPFAULTERRORBOX = &H2

   Public Declare Function SetErrorMode Lib "kernel32" (ByVal wMode As Long) As Long

then we can just call it :

SetErrorMode SEM_NOGPFAULTERRORBOX

but this should be carried out just outside the IDE (Integrated Development Environment) =outside the VB design environment = as EXE

To detect if we are in the IDE or not we can use a simple method (by Steve McMahon) :

'In the General part of the declarations area:

   Public m_bInIDE As Boolean

Public Property Get InIDE() As Boolean

	  Debug.Assert (IsInIDE())

	  InIDE = m_bInIDE

   End Property



   Private Function IsInIDE() As Boolean

	  m_bInIDE = True

	  IsInIDE = m_bInIDE

   End Function

Now we can use the property InIDE to detect if we are in the IDE or not (Returns true if we are in the IDE & False if not).

So we can call the SetErrorMode as follow :

If Not InIDE() Then

	  SetErrorMode SEM_NOGPFAULTERRORBOX

   End If

GPF snapshots :

Err1.jpg

Err2.jpg

-----------------------------------------------------------------

Standard VB Frame problems with XP styles :

The lack of hDC property for the VB frame cause 3 problems :

  • It does not show XP syles even with the above code.
  • It flicker with mouse movement.
  • Controls on it appear in a weird manner (see the following snapshot) , this mainly occur to the Option buttons and command buttons borders but with some themes it occur to other controls

FrameError.jpg

The 3rd problem can be resolved by using another container (ex.: a border-less Picture-Box)over the frame to hold (contain) the controls instead of the frame itself.

The only available way to avoid all these problems is to use another frame control , here is a free , open sourced & efficient frame :

Replacent Frame Control for XP

-----------------------------------------------------------------

Other controls that show XP styles with no effort (All by VB & All are open sourced) :

LaVolpe Buttons

dcButton ActiveX Control

McToolBar 2.3

XTab

Candy Button

vbAccelerator Toolbar and CoolMenu Control v3.5

vbAccelerator Progress Bar Control

Media Progress Bar

vbAccelerator Explorer Bar Control

vbAccelerator No Status Bar Control

vbAccelerator TabStrip Control

vbAccelerator Visual Studio Style Tab Control

vbAccelerator MDITabs Control

-----------------------------------------------------------------

For easier and faster XP styles addition I made a project that can be added to your VB projects templates

<Program Files path>Microsoft Visual StudioVB98TemplateProjects

Click here to download a self extracting file contain that project

This will add 4 files :

  • frmMain.frm
  • MainMod.bas
  • Standard EXE with XP Styles.vbp
  • Standard EXE with XP Styles.vbw

When you open your VB 6 a new item will appear in the New Project window named : Standard EXE with XP Styles.

Select it and you will have a project with a form (frmMain) and module (MainMod).

When you select to save your project VB will not ask you to save the module , I have no solution for this problem but you can save it manually or make any change in that module then undo it then the VB will ask you to save it with the rest of the project.

SelectPrjType.jpg
#2

عمو محمد فينك ياسيدى انت تشرح باى لغة انشلة اللغة الفرقشتانية :lol: هو الشرح ده كان فى المنتدى التانى ولا ايه ;)

موقع البرنامج

مبارك لشعب تونس photo-thumb-42837.png

#3

انا كنت استعمل هذة الطريقة منذ قديم الازل لكننى لم اكن اعرف ما هو الملف manifest وكل تلك الجمل يمكن ان تتلخص فى كلمتين اثنين لمن لا يريد الاطالة

اولا كود الخاص باستخدام الادوات القياسية الخاصة بالويندوس

Declare Sub InitCommonControls Lib "comctl32" ()

Private Sub Form_Load()
InitCommonControls
End Sub

طبعا مع تسمية اسم الملف التنفيزى بعد ترجمته باسم المكتبة manifest

واعزرنى اخ محمد فهناك الكثيرون من لا يتقنون اللغة الانجليزية واذا كان عندك الوقت للترجمة ارجو ان تفعل اذا كان ذلك لن يؤثر عليك (h) :( :( :(

موقع البرنامج

مبارك لشعب تونس photo-thumb-42837.png

#4

صعب أنى أترجم كل ده

حريف برمجة كتب:
هو الشرح ده كان فى المنتدى التانى ولا ايه ;)

ايوه كان فى منتدى تانى بس برده أنا اللى كنت كاتبه من الأول للآخر ;) و المره دى معدل عليه كمان.

بس ماكنش فى الـ vbforums

تم تعديل هذه المشاركة بواسطة msayed2004 في 10 مارس 2007 في 01:39

#5

انا بعد كدة هعمل بحث فى جوجل على Msayed2004 عشان الاقى موضيعك الى انت مشتتها :lol:

انا مش شايف ليه رد الاعضاء هو الموضوع صعب اوى كدة

موقع البرنامج

مبارك لشعب تونس photo-thumb-42837.png

#6

ما فـــائدة XP Styles ؟

قطرة الماء تـثـقب الحجر.. لا بالعنف. لكن بتكرار المحاولة

at4re.gif

منتديات الفريق العربي للهندسة العكسية 不喜欢的勿入! www.at4re.com

#7
dj-siba كتب:
ما فـــائدة XP Styles ؟

فى مبرمجين VB كتيير و اجهم مشاكل مع عملائهم بسبب كده لأنهم بيحبوا كل برامجهم تاخد نفس الـ Theme اللى بيحبوها

وفى الأول و الآخر ده موضوع جمالى لمشروعك و بالحل اللى أنا حطه فى آخر المشروع محدش هيتعب فيها

#8

begin.gif

180.gif

يعطيك العافيه اخ msayed2004 على ما تقدم من معلومات ممتعه بحق وخصوصا انها مبنيه على

الشفرات فقط .. وهذا بحد ذاته يقلص عملية اضافة الاداوت في البرامج وقد تفيد من هم لا يعرفون سو السرعة في انجاز ما يريدون :lol:

على العموم اخ حريف برمجة اول المتفاعلين مع الموضوع وهذا ليس بغريب عليك الله يعطيك العافيه

وفعلا كما تقدمت اخ msayed2004

ان هناك من هم يفضل الشكليات في برامجه وانا احدهم B)لآنها تعطي دافع على كمال الوجه الاخر من البرنامج وتميز المبرمج

وذوقه وكنت آنا ذاك لأتقن عملية اخذ ثيمات XP استخدم شفرة التلامس وهو صنف من أصناف

API يسمى بـ INITCOMMONCONTROLSEX_TYPE

كما ذكرتموها ولكن بطريقة مختلفه وكانت تركيبتها كالتالي ..... كنوع من الاضافة للموضوع ان كنت تسمح طبعا

حيث سنحتاج الى Module1 نضع بداخله الآتي

Public Type INITCOMMONCONTROLSEX_TYPE
	dwSize As Long
	dwICC As Long
End Type
Public Declare Function InitCommonControlsEx Lib "comctl32.dll" (lpInitCtrls As _
	INITCOMMONCONTROLSEX_TYPE) As Long
Public Const ICC_INTERNET_CLASSES = &H800

وقم برسم اداوت على الفورم من اي نوع كــ

Option1

Command1

Text1

Combo1

VScroll1

وفي حدث Form_Initialize

Private Sub Form_Initialize()
	Dim comctls As INITCOMMONCONTROLSEX_TYPE
	Dim retval As Long
	With comctls
		.dwSize = Len(comctls)
		.dwICC = ICC_INTERNET_CLASSES
	End With
	retval = InitCommonControlsEx(comctls)
End Sub

وكما تفضل الاخ حريف برمجة فالشفرات متعددة فمنها ما هو مختصر ومنها ما هو مطول وذلك راجع على من ابتكرها وانت بمقدورك ان تبتكر افضل منها ... فهي البرمجة وهي المتعه 87.gif

ولو تلاحظ 016.gif الشفرة التي وضعتها أنا ووضعها الاخ msayed2004 والآخ حريف البرمجه انها تعتمد على بدرجه الأولى على مكتبة comctl32.dll

وهذه هي المكتبات الرئيسة لنظم التشغيل Windows. وباقي الملفات تعتبر فرعية لاداء اغراض معينة. فمكتبة COMCTL32.DLL هي خاصة بادوات Windows الشائعة Windows Common Controls والتي ظهرت منذ الاصدار Win95

يعني ان هذه الشفرة ستتماشى مع كل اصدارات XP بما فيها الفيستا بما ان هذه المكتبة موجودة

هذا ما اردت المشاركة به من اجل تدعيم الموضوع بما أنه يتكلم على نفس الجانب ... وبالتوفيق للجميع

تم تعديل هذه المشاركة بواسطة HnHn في 10 مارس 2007 في 19:53

سجل ايميلك هنا

googlejb5.gif ليصلك كل ما هو مفيد في عالم البرمجة
#9

لم اكن اعلم ان الموضوع سياخذ كل هذا القدرمن الاهمية وشكرا لم اخى HnHn على تشجيعك وعلى اضافتك المتميزة ولكن للعلم تجميل البرامج من المواضيع المهمة جدا ويمكن ان يكون احد البرامج على قدر كبير من الكفائة ولكن شكلة ليس كما ينبغى وياخذ اسيضا شكل الاكس بي باخنصار ان البرنامج التجارى الذى يعمل على الاكس بى وياخذ شكل ويندوس 9x هو برنامج غبى ومبرمجة اغبى فاصبح المستخدمين الان ينظرون للبرنامج من حيث الواجهة

ولكن كما اجمع الجميع ان استخدام الادوات غير مجدى لاسباب كثيرة منها انها ثقيلة على المعالج ويمكن سرقتها من البرنامج فيكفى اخذ ملف الاداه من مجلد البرنامج ولكن الطرق لم تنتهى عند هذا الحد فهناك فكرة اخرى وهى دمج الاداه مع البرنامج اى عمل user control ويتم ترجمتها مع الملف التنفيزى ولذك يمكننا الخروج عن شكل الويندوس اكس بى التقليدى + ان برامجنا ستعمل بنفس الزيم مع نظم التشغيل الاقدم (النوافز)

موقع البرنامج

مبارك لشعب تونس photo-thumb-42837.png

#10

أضافة متميزه من الأخ هانى كما عهدنا منه , شاكر جدا ليك و لكل المهتمين بالموضوع.

#11

كان شرحا تفصيلا رائع نأمل ان تكون جميع الموضيع بهذا الشرح

اشكرك بشده

Keep Going..=>

ONLY GoD CaN JuDGe mE

#12

ماأشتغلت معي الطريقه ... يمكن انا مافهمت؟

مطلوب برنامج للبيع

هل لديك برنامج للبيع.نحن هنا لنساعدك

امازون العرب

مالفائدة اذا لم تسوق برامجك

#13

حاول تستعمل الـ Template لاحظ أن الويندوز لازم يكون بيدعم الـ XP Styles و تجرب الموضوع ده كـ EXE و ليس من داخل الـ VB

#14

للأفاده راجع : XP Style for Visual Basic

بالتوفيق ,,,,,,,,,

A7med_prof

اقتباس

آسف الدخول متقطع هذه القتره

اقتباس

[يمين]

.[/يمين]

A7med_prof-4-2007.jpg

اخر مواضيعي 2007

االمثال مطبق على موقع بورصه سعودي

.

.

مواضيع مهمه ومطلوبه بكثره VB6

.

بــرامج ومشــاريع عربيه كامــله {HnHn} والمزيد في قسم برامج الاعضاء || ربط قواعد بيانات اكسس مع الفيجوال بيسك, مادة دراسية كاملة {بنت اليمن}|| المرجع الشامل لجمل SQL ا {GENIUS-IT} || كيفية التعامل مع مكتبة الـ DAO, في الوصول إلى قاعدة بيانات {رمضان} || مثال ريط Visaul Basic 6.0 مع SQL SERVER ا || العمليات التي تجرى على قاعدة البيانات, مثال كامل {بنت اليمن} || تصدير البيانات من الاكسل الي الاكسس بالفيجوال بيسك {HnHn} || البحث في قاعدة البيانات {MANSUR} || قواعد البيانات العلائقية وتقنيات الوصول إليها {عبد الله فتحي} || كيفية أظهار بيانات جدولين بواسطة التاريخ ,,,,,,,

.

أخي ربما سؤالك اجابته في أحدى هذه المواضيع فإن لم تجد قم بالبحث وان لم تجد اطرح سؤالك مع وضع عنوان مناسب بحيث ان يكون هذا العنوان دال على محتوى الموضوع فغير ذلك من أكبر الكبائر في المنتدى وسيؤدي الى غلق او حذف موضوعك .

.

</
#15

بارك الله فيك

اذا لم ننهض بأنفسنا فلن نستطع ان ننهض بأوطاننا

م/ محمود عبد العزيز

مهندس الكترونيات واتصالات

مصـــــــــــــــــر

#16

عايز أعرف حاجة بالنسبة للملف manifest يعني لازم يكون موجود امام الملف التنفيذي؟

يعني مفيش طريقة أستغني بيها عن وجوده يعني ؟

#17

لأ

و عندك حلين يا أما طريقتى أو حفظة كـ Resources و أستخراجة (أبطأ) , عموما أنت مش محتاجة بعد تطبيق الـ Styles على الأدوات.

#18

السلام عليكم ورحمة الله وبركاته

على ذكر ال resources عندي ملف فيه ال manifest ولا تحتاج الى استخراجه

هل تصدقون ؟

يعني فقط عليك اضافته الى مشروعك وعمل InitCommonControls وستحصل على نفس النتيجة

سأرفقه في المرة القادمة ان شاء الله

#19

موجود على موقع http://www.vbaccelerator.com/home/index.asp لكن أعتقد أنه من الضرورى أستخراجة , عموما نراجع المشروع اللى على الموقع.

#20

أهلا مجددا

كنت أفكر مثلك أخي لكن عليك تجربة الملف

في الموقع الذي أوردته يتحدث عن الطريقة

اقتباس
A more robust method is to compile the manifest as a resource in your application. To do this, the manifest must appear as resource type RT_MANIFEST (24) with id CREATEPROCESS_MANIFEST_RESOURCE_ID (1). For some bizarre reason, you must also ensure that the resulting XML file is an even multiple of 4 bytes long. So for example, if your file is actually 597 bytes you need to add padding spaces to make up the file size to 600 bytes before compiling. The Resource examples demonstrate how to create this resource file using a resource compiler script (.rc file) and RC.exe.

بالتوفيق ان شاء الله للجميع

MyRes.zip

تم تعديل هذه المشاركة بواسطة DreamNet في 25 مايو 2007 في 20:08

#21

فعلا أنا جربت الملف

وطلع عندي نفس النتيجة بدون ماستخرج الملف من الروسورس

طيب ممكن أستفيد من الطريقة دي في وضع ملف الصوت

متشكرين على الملف

هذا الموضوع مغلق.

مواضيع مشابهة