Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




GDI CreateCompatibleDC - Hatched Styles?


OK this is driving me crazy:
I wrote this code to create a back buffer DC and fill it with a colour:


Code:
GetWindowRect hwnd, WinR

aRect.Right = 40
aRect.Bottom = WinR.Bottom - WinR.Top

hDC = GetWindowDC(hwnd)

mDC = CreateCompatibleDC(hDC)
hBitmap = CreateCompatibleBitmap(mDC, 40, WinR.Bottom - WinR.Top)
DeleteObject SelectObject(mDC, hBitmap)

hBrush = CreateSolidBrush(RGB(222, 222, 222))
FillRect mDC, aRect, hBrush
DeleteObject hBrush

Technically, this works, but when I Blt it to a control, it appears that the DC has some hatched style over the top, even though I used CreateSolidBrush

Can't seem to find a way around this, hoping someone knows.

Thanks.

EDIT: Sorry, posted the thread in the wrong place... Can someone move it?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
CoolBar+XP Styles+Toolbar <> XP Styles
I am having trouble getting the styles on the toolbar and coolbar to work together. When I add a manifest file the project the coolbar gets the new XP style and the toolbar is still flat and gray. Is there anyway around this?

CreateCompatibleDC
When you use CreatecompatibleDC(&0) create a compatible with the screen.
Few years ago the screen was 24bpp today the screems are 32bpp.
What happen with this.
We use to create a compatible and then draw and work with the DC, in 24bpp because the frame grabber work with 24bpp, what will happen when I use BitBlt to paint in the screen.
Could I use Create CompatibleDC(&0) and create the binfo with bitsperpixel=24 in order to receive the frame capture?


...Julio

Createcompatibledc
hdc as long

hdc = CreateCompatibleDC(0)

I'm getting a negative result in hdc. Is this an error condition?

I'm having a GetDIBits call crash VB later in the program and I'm wondering if this is the problem?

CreateCompatibleDC...
I have been learning the different aspects of game programming in VB lately before I undertake a larger game project. Currently I am trying to learn how to open graphics straight into memory (no picture boxes involved) and then use them with BitBlt from there. It makes sense how it CAN work but for me it just WON'T work. I have downloaded 3 different examples and tried to use them but none of them seem to work the way I want them too. I know that I use some API's like CreateCompaitbleDC, DeleteDC, BitBlt, ect. But I can't seem to get the image into memory. So can anybody point me to a good tutorial or help explain the different steps that need to happen? Thanks.

CreateCompatibleDC
Well, I've heard of it, read a little bit about it, can't really find much about it on the forums.. so

How do I use it??

I have a bitmap, that i want to load into memory, so I can bitblt using the DC in memory..

how can I acheive this?

Thanks in advance,

CreateDC() And CreateCompatibleDC()
Can someone tell me,
what's the difference between CreateDC() and CreateCompatibleDC()

Problem With CreateCompatibleDC()
I am using CreateCompatibleDC() in my code, and the problem is that it is only working to load the picture half the time. Here is the function I use.

Code:
Public Function CreateDC(FileName As String) As Long

Dim DC As Long
Dim hBitmap As Long

'Create a Device Context
DC = CreateCompatibleDC(frmZeldaMapEditor.picTileset.hdc)

If DC < 1 Then 'Failed
GenerateDC = 0
MsgBox "Error creating DC"
Exit Function
End If

'Load image
hBitmap = LoadImage(0, FileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION)

If hBitmap = 0 Then 'Failed
DeleteDC DC
GenerateDC = 0
MsgBox "Error loading image"
Exit Function
End If

'Loads the image into the DC
SelectObject DC, hBitmap

'Returns the DC
CreateDC = DC

DeleteObject hBitmap

End Function

The problem is that I am getting the "Error creating DC", indicating a problem with CreateCompatibleDC(), approximately 50% of the time. Obviously this is unacceptable as the program is unuseable when this happens. Is there something I am doing wrong. If you need more info please let me know, Thanks.

CreateCompatibleDC Always Returns 0
Hi,

I am just experimenting with CreateCompatibleDC, in order to BitBlt from memory, but it always returns 0. I am using VB6 and running on Windows 2000 Pro.

As I have never used these APIs before, I don't even know where to look, can anyone help me?

Thanks in advance

CreateCompatibleDC - Do It Once, Or Each Time?
My usercontrol has an option to tile the background with a bitmap. This is an owner-drawn control so the actual bitmap will not be saved in something with a hdc property. Should I...

1. create a memory dc each time the control is redrawn using only local variables and destroy them at the end of the sub?

2. or just create a module-level memory dc if/when a backgroundbitmap is assigned and reuse it each time.

I am not sure what kind of resources it would use up, and I am new enough at all this GDI stuff that I am still confused about how to prevent memory leaks. Thanks


God Bless America

Difference Between CreateDC And CreateCompatibleDC
As the title says, whats is the difference of CreateDC and CreateCompatibleDC, always I had this doubt.

Thanks !

A Problem With CreateCompatibleDC, My Computer, Or My Brain?
A good 3-4 times out of 5, when using CreateCompatibleDC (Context included later), a handle is returned whose value is < 1. I've made my own set of code from scratch, tried various examples from here on xVBt, and I'm consistantly encountering this problem. While I can work around it, it's certainly a hassle, slower, and I'd prefer to understand why it's happening, even if I can't fix it.

The following is code from SOMEONE's mDC tutorial from here, just spent 15 minutes looking for where I got it from, can't find it.


Code:
Public Function GenerateDC(FileName As String) As Long
Dim DC As Long
Dim n As Integer
Dim hBitmap As Long

'Create a Device Context, compatible with the screen
DC = CreateCompatibleDC(0)

If DC < 1 Then
GenerateDC = 0
Exit Function
End If

'Load the image....BIG NOTE: This function is not supported under NT, there you can not
'specify the LR_LOADFROMFILE flag
hBitmap = LoadImage(0, FileName, IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE Or LR_LOADFROMFILE Or LR_CREATEDIBSECTION)

'If hBitmap = 0 Then 'Failure in loading bitmap
' DeleteDC DC
' GenerateDC = 0
' Exit Function
'End If

'Throw the Bitmap into the Device Context
SelectObject DC, hBitmap

'Return the device context
GenerateDC = DC

'Delte the bitmap handle object
DeleteObject hBitmap

End Function

Where the line 'DC = CreateCompatibleDC(0)' often produces negative numbers. What is causing this?

XP Styles
Hi all!
I have some projects that use XP Style visualization if the operating system is Windows XP; I also prevent errors that occour (in some circumstances) when you close the program.
The question is simple:
Can I use XP Style when the program runs in the IDE?

XP Styles
Hi, im trying to get my app to use the xp styles (as you probably guessed). Ive looked at http://www.vbaccelerator.com/home/VB...VB/article.asp and i swear i follwed it to the letter but my app will not load, i just get an error sound from my speakers.

I copyed and pasted the manifest code and this is what ive got in my app:


Code:
Private Const ICC_USEREX_CLASSES = &H200

Public Function InitCommonControlsVB() As Boolean
On Error Resume Next
Dim iccex As tagInitCommonControlsEx
' Ensure CC available:
With iccex
.lngSize = LenB(iccex)
.lngICC = ICC_USEREX_CLASSES
End With
InitCommonControlsEx iccex
InitCommonControlsVB = (Err.Number = 0)
On Error GoTo 0
End Function

Public Sub Main()
InitCommonControlsVB

End Sub

Private Sub Command1_Click()
MsgBox "test Message"
End Sub

I complied it as test.exe and my manifest is called test.exe.manifest
Ive tryed:

Code:
Public Sub Main()
InitCommonControlsVB
Private Sub Command1_Click()
MsgBox "test Message"
End Sub
End Sub

and as expected that didnt work either.

i think im doing something thats so obvious that im gonna look stupid for posting this :/

Tab Styles
I am trying to use the tab style on a form, but I can not get the color to change from that horrid grey... the controls will only let me change the background color, not the app work space... anyone?????????

Styles
I want my documents to be formatted with Heading 1 and Body Styles. I have a macro to format with heading1 and another macro to format with body style.

After I put my heading in Word wants to use the normal style. I tryed to changed normal.dot to show that the style following heading 1 should be body but no matter what I do it seems Word changes it back to normal.

What is the correct way to change Heading 1 so that body style always follows it?

XP Styles
Helo
I m using windows XP.Can i use Win XP Style in my VB Application that will also work in win98 and win ME.
Bye.....

XP Styles Help [vb6]
I need to add XP Styles to my Project.

Can someone link me to a tutorial?

-Andrew

XP Styles In VB6
I've gotten VB6.EXE to load XP styles with this 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="A.B.C"
type="win32" />
<description>Name</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*" />
</dependentAssembly>
</dependency>
</assembly>

VB6.EXE loads fine and loads the style fine, and my app has the VB style, but when I compile my app and try the manifest with that, my app opens then immedietly closes.

XP Styles
I've searched high and low for how to do this, and I keep seeing http://www.vbforums.com/showthread.php?t=234280&highlight=winXP+Styles same solution to getting my app to show as XP style app. However, I cannot seem to get it to work, at all.

I've saved the manifest file as myappname.exe.manifest and included the required code in my main app form, as well as attempted it in my main startup sub.

These are some screenshots of references and components. When I try to add the comctl32.dll I get a "Can't add a reference to the specified file" error.

For some reason these linkswon't click to the pics, so you'll have to copy then to you browser...
http://comlinkonline.tripod.com/foxardevelopments/references.jpg
http://comlinkonline.tripod.com/foxardevelopments/addreference.jpg
http://comlinkonline.tripod.com/foxardevelopments/components.jpg

How Can You Add XP Styles To A Dll?
I have a dll that loads when microsoft outlook is loaded..

this dll also has a form with it, one that loads when a button is clicked in outlook. How can i get this form to have XP Style?

Win XP Styles
could someone show me a source code on how 2 use WinXP visual styles in VB apps?

App Styles
Are there any available toolkits for VB that give different style UI frameworks ?? Such as DevStudio, Outlook, Explorer etc....

I suppose I am really looking for the VB equivalent of the MFC CJLibrary at CodeGuru... Is there such a beast ???

Hope someone can help

Steve.

Manifest XP Styles
I have successfully installed the .manifest from posts on this site. This is the result that I get.

Things to notice:
The Frame around Marital Status is not like the other frames (option controls used inside frame) and the command buttons are not drawn correctly.

Here is the fix ---
From previous threads, I have read that placing a picture box on the screen would solve the option control to display correctly. I applied this theory to both frames within a frame (as in my case) and command buttons within a frame

I set the border style property of the picture box to 0 - None. Place the picture control inside the frame and then place the control inside the picture box.

Hope this helps for anyone else dealing with manifest files or XP Styles

Help Making Vb6 Use Xp Styles
i found a script that lets me use window xp buttons in visual basic 6 apps. u know the cool looking rounded buttons. do u know how i can have everything be xp style? like textboxes,progressbar,check boxes,radio boxes, and those stuff. i tried google but i could only fidn stuff for vb.net if u know any dlls or user control scripts then could u plz tell me?

Visual Styles
I have looked, and looked.And darn, still have not found a thing on it.
What I want to do is make a Visual Style editor/maker, but I have not found a thing on how a visual style is even made.Is it just a 'manifest' stored somewhere for the entire system?

Border Styles
Heres a question I need solved. What if one of your main forms is using a border style of fixed single(1) When running the application and you press the close icon at the top right, how do you get it to end the process as currently it seems to hide the application but not end the process

Much help would be appreciated.

XP Styles Flicker
I've been changing my app over to use XP styles following the suggestions in many of the posts here and elesewhere.
Everything is fine except for two things...

1.) The captions of some frames are cut short. I've messed with a few settings, like using the Button Face color, and changeing the font size, and type. But nothing seems to work.

2.) As I mouse around the forms, the label controls flicker.

Any ideas on this would be helpful. Thanks.

Converting Map Styles
I'm currently making a 2D rpg using DX7 Fullscreen DD. I have my current map system where each map is a screen big and when users hit the edge it moves them to a new map. I want to know how to go from this poor method to having larger Areas that are scrolling. When I say areas, I mean I dont want the whole world to be one map, I can split it up into a bunch of areas. I just want each area to be bigger than 1 screen size.

Alright, I've repeated myself enough.

So how would I save/load a map larger than the screen size? How do I tell it to blt only a certain section of the map?

PS: I'd also like to point out that this game is tile-based so using one fat picture won't do. 32x32 are the tile dimensions.

Thanks in advance,
- Vinx

Many Copys Of My Styles
Hi,

I have the following problem:

I have a macro in MS Excel that opens a Word-file and adds some subdocuments. I'm using this command:

<document>.Subdocuments.AddFromFile(<filename>)

It works pretty good, except I have a lot of copys for every Style after that. For exemple:

MyStyle
MyStyle1
MyStyle2
MyStyle3
...

When I open the Masterdocument myself and add the subdocuments manually a popup appears that askes me to rename the styles of the subdocument. When I answer "No" everything's fine. But I didn't find any attribute that could tell Word to not rename the styles.

Any ideas?

Thanks a lot
Unrockbar

Button Styles
Are there any alternative button styles available for VB??

Cell Styles In Vba?
Hi everybody,

I can get the style of a cell in vba, btu if one cell contains multiple styles (bold etc) and multiple colors, is there a way to get these per character?

thnx!
smeaggie

CmdButton Styles
Hey all,

This one's really stumped me big time.
Ok, cmdButtons right? They look 3D. But in some programs, (eg Internet Explorer) the toolbar is not 3D until you put your mouse over the buttons; then when you move your mouse out again, they go back to flat.
How do I do this????

Cheers all.

Chief

"Dammit Smithers, this is brain surgery not rocket science!! Now hand me that ice cream scoop..."

Border Styles
I use the following code (from PlanetSorceCode.com) to set the border style of a user control. The code works great, I was wondering if anyone knows the constants for other border styles.


Code:
''## Border Styles
Private Const GWL_EXSTYLE As Long = (-20)
Private Const GWL_STYLE As Long = (-16)
Private Const SWP_NOMOVE As Long = &H2
Private Const SWP_NOSIZE As Long = &H1
Private Const SWP_NOZORDER As Long = &H4
Private Const SWP_NOACTIVATE As Long = &H10
Private Const SWP_FRAMECHANGED As Long = &H20 ' The frame changed: send WM_NCCALCSIZE
Private Const SWP_NOOWNERZORDER As Long = &H200 ' Don't do owner Z ordering

Private Const WS_EX_CLIENTEDGE As Long = &H200
Private Const WS_EX_STATICEDGE As Long = &H20000


Public Property Let Appearance(ByVal New_Appearance As AppearanceConstants)
Dim lStyle As Long

menmAppearance = New_Appearance
lStyle = GetWindowLong(UserControl.hwnd, GWL_EXSTYLE) 'Retrieve current style

Select Case New_Appearance 'Toggle style flags
Case [Flat]: lStyle = lStyle And Not WS_EX_CLIENTEDGE And Not _
WS_EX_STATICEDGE
Case [3D]: lStyle = lStyle Or WS_EX_CLIENTEDGE And Not WS_EX_STATICEDGE
Case [Thin]: lStyle = lStyle And Not WS_EX_CLIENTEDGE Or WS_EX_STATICEDGE
End Select

SetWindowLong UserControl.hwnd, GWL_EXSTYLE, lStyle 'Apply changes
SetWindowPos UserControl.hwnd, 0, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_NOZORDER Or _
SWP_FRAMECHANGED Or SWP_NOSIZE Or SWP_NOMOVE
PropertyChanged "Appearance"
End Property

XP Styles And Frame
Hello

I made my program have xp styles on it with a manifest file.
Now my frames are shown differently ( as expected ), but no matter what i do I can't change the forecolor of the frame anymore.. It's always kinda blue

what can i do to make it white or something??

How To Add Xp Visual Styles To Vb6.0
How to add xp visual styles to vb6.0 forms & controls.

WinXP Styles!
A silly question probably but still asking..............

I have come across many posts in this forum which tell how to incorporate XP styles in a VB app. What I want to know is do those codes render the XP styles to a VB app when the app is run in WindowsXP only? If the app is run in some other OSs like Win2K or Win98 SE, won't the app render the XP styles using that code?

Problem With XP Styles
Ok I have an application in VB6 and i am trying to apply XP styles to the app. The styles apply fine, but when there is a button on a frame it draws a black box around the button. Also with checkboxes or radio buttons on frames they caption just shows up as a blacked out box. Is there any way to correct this or is the only solution to take them off of frames? Any help would be appreciated. thanks.

XP Styles Issue
I ran in to an interesting problem with VB6 (using SP6 on a WinXP Pro Box w/ SP2 installed.) today. When I add a ListBox control to a from the scroll buttons appear using the XP Style rather than the standard style for VB6.

So far this is the only Common Control I've noticed doing this. I installed VB6 and SP6 on a fresh machine. Created a new project and dropped a ListBox control on a form; no change.

In my searches I found KB884883 on Microsoft's site that described a problem similar to mine if the PC had versions 5 and 6 of the common controls. I tried installing the patch on my test machine and still no change. I haven't yet seen any information pertaining to this issue.

Also in my searches I noticed that there is a way to change the controls to display using the XP Style if you create a manifest file. Figuring I'd do this to make the controls on the form match I created a manifest file, etc. This is where I ran in to a second problem. The Date Picker control does not display using the XP Style. I'm having a hard time figuring out why it won't display properly.

Could anyone give me some insight in to either issue?

Thanks much in advance.

Windows XP Styles
Hello, I have created several programs and want to enable them to use Windows XP style form controls. I am currently using Manifest files for each program but am wondering if there is a way of implementing something into the code to do this instead. There must be someway of doing this as the majority of programs do not have Manifest files but still seem to use the Windows XP theme.

I would also like to know why when I use an icon file for my forms, the 16 colour icon is used on the title bar. Is there way of making it use the 32-bit icon format instead!

Please let me know. Thanks in advance!

Window Styles
What window style could I use to allow for the cursor to be placed on the right hand side of a textbox, instead of the default left hand side?

Button Styles...
Ok....you can make funny shaped forms, what about... circle Command Buttons? I was going to create a form and have the buttons fit really well with the form, like on Windows Media Player.

Do I have to create my own button, or can I do it with some coding similar to a form?

Webbrowser + Styles
I am using the web browser control in my project and i need to use styles. The problem is that i need to be able to change the style sheet for the page. I can achieve what i need by saving everything to a temp file and then loading that file into the webbrowser. The problem with this is that each time i need to reload the page (i do this lots), is that it clicks each time.

I am using the webbrowser1.Document.body.innerhtml to set the body of the page, but i dont know how to load the styles. Can anyone help me??

Thanks.

XP Styles 2nd Episode
Thanks again for those who replied in "XP style". I'm starting this new thread is because the manifest file I receive works with all the controls except the toolbar.

I tried including components from SP2 to SP5. The tool bar conversion to XP style works fine with SP2 but not the newer versions. How can this be? And how do I solve it?

Regards,
Thundura

Resotre CR Styles
Hello guys,
I need some help with a nasty problem.

I got this code that clears up ^13 character styles.

Code:    
     objSelection.HomeKey 6 'wdStory
     objSelection.Find.ClearFormatting
     objSelection.Find.Replacement.ClearFormatting
     objSelection.Find.Replacement.Style = objDoc.Styles(&HFFFFFFBE) 'wdStyleDefaultParagraphFont
     With objSelection.Find
     .text = "[^13]" ' "[^13^9]"
     .Replacement.text = "^&"
     .Forward = True
     .Wrap = 1
     .Format = True
     .MatchCase = True
     .MatchWholeWord = False
     .MatchWildcards = True
     .MatchSoundsLike = False
     .MatchAllWordForms = False
     End With
     Call objSelection.Find.Execute( , , , , , , , , , , 2 )



However after the script finishes its work, I need to restore the styles of the ^13 characters.
Currently I'm trying to loop back the paragraph styles, looking for ^13 characters and setting styles,
but it seems a bit wrong to me

Code:
   For i = objDoc.Paragraphs.Count - 1 To 1 Step -1
     
      Set par = objDoc.Paragraphs(i)
      
      If (Asc(par.Range.Text) = 13) Then
       par.Range.Style = "NORMAL"
       par.Range.Font.Size = 11
      Else
       Exit For ' exit on the first text paragraph
     End If
        
   Next




Is there an easy way to do that, besides keeping an array of styles or anything ?

thanx





Edited by - peter_g on 9/1/2005 11:04:52 AM

View Text Using CSS-Styles
Hi,
is there a way to make RichEdit/Textedit EDIT AND show Text using original CSS-Styles with all its features?

I basicly need to make a text-editor where you can edit AND view Text using original CSS-styles, 1:1 as you would see it later in a Browser. The user is not allowed to mark Text to make it bold/italic etc.., he has to use a CSS-Styles to format his Text.

There is a great OCX-control (http://nbit.net.au/home.aspx) where you can edit a Webpage in WYSIWYG-style, but this OCX handles all Keyboard-input by itself and doesn't have any .selstart, .selenght etc. methods. Its useless for my 'Straight CSS-Style Texteditor".

Thanks in advance for anything pointing me into the right direction.

Font Styles In A List Box
Hi

I have a list on my program. I want to the listbox to display a line of text but i want a few of the words in bold. I currently have

List1.AddItem ("Click Yes, No or Cancel")

I want the Yes, No and cancel in bold

Can this be done?

XP Styles In Windows 9x/2000
Hi!

Is there any good way to use/have windows xp styles for controls in windows 9x or 2000?
I'm using .manifest for xp but i don't know how to do the same in the above mentioned OS

Any idea or ActiveX known component???

Thanks!

Update Styles With Macro
We are altering the format of our firm's documents. I need to create a script that runs over the document, updating it to the new style. The new style is basically changing the font to Times New Roman, and changing to sentence case.

I am having trouble updating those styles (I am using Word2002, and styles SUCK in this version). I can easily get the standard font itself to change, but not the numbering style.

I have to use options because the style level differs from a standard document to a deed or agreement (i.e heading 1 is bold, caps in an agreement, but just number 1 in normal document).

I am loathe to copy the script in here as it is a long one, so will edit the repetitive information out. Is there a cleaner way of just "updating style" to template?. I put two coding below, one is my first attempt, and my second.

Also, does anyone know of a realllllllly good advanced word forum? My main gripe with word2002 is how it thinks toooo much for itself. I want to stop it automatically adding styles with every different format, and only list my standard ones.. try as i might and deselect everything, it won't!! (see my code at end of each script below to try and get it to stop!)


Code:
Private Sub CommandButton1_Click() 'ok button
Dim iType As Integer


'get value from option buttons to use in subsequent case statements
If Me.OptionButton1 Then iType = 1
If Me.OptionButton2 Then iType = 2


'close user form
Me.hide
Unload Form2003


Select Case iType
Case 1 'Deed/Agreement

With ActiveDocument.Styles("Normal").Font
.Name = "Times New Roman"
End With
With ActiveDocument.Styles("Heading 1,1.").Font
.Name = "Times New Roman"
.Size = 14
.AllCaps = False
End With
ActiveDocument.Styles("Heading 1,1.").NoSpaceBetweenParagraphsOfSameStyle _
= False
With ListGalleries(wdOutlineNumberGallery).ListTemplates(4).ListLevels(1)
With .Font
.Name = "Times New Roman"
End With
.LinkedStyle = "Heading 1"
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(4).ListLevels(2)
With .Font
.Name = "Times New Roman"
End With
.LinkedStyle = "Heading 2"
End With
'etc etc
ActiveDocument.Styles("Heading 1").LinkToListTemplate ListTemplate:= _
ListGalleries(wdOutlineNumberGallery).ListTemplates(4), ListLevelNumber:= _
1
With ActiveDocument.Styles("Heading 1,1.").Font
.Name = "Times New Roman"
.Size = "14"
End With
With ActiveDocument.Styles("Heading 1")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "Body Text Indent"
End With
With ActiveDocument.Styles("Sched/Annex").Font
.Name = "Times New Roman"
.AllCaps = False
End With
' and so on and so on

'hide all but current heading styles

With ActiveDocument
.UpdateStylesOnOpen = False
End With
ActiveDocument.FormattingShowFont = False
ActiveDocument.FormattingShowClear = False
ActiveDocument.FormattingShowParagraph = False
ActiveDocument.FormattingShowNumbering = False


Case 2 'Plain/Letter

With ActiveDocument.Styles("Normal").Font
.Name = "Times New Roman"
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(5).ListLevels(1)
With .Font
.Size = 14
.Name = "Times New Roman"
End With
.LinkedStyle = "Heading 1"
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(4).ListLevels(2)
With .Font
.Name = "Times New Roman"
End With
.LinkedStyle = "Heading 2"
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(4).ListLevels(3)
With .Font
.Name = "Times New Roman"
End With
.LinkedStyle = "Heading 3"
End With
'etc etc
With ActiveDocument.Styles("Heading 3,(a)").Font
.Name = "Times New Roman"
End With
With ActiveDocument.Styles("Heading 3")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "Body Text Indent (a)"
End With
'etc etc
ActiveDocument.FormattingShowFont = False
ActiveDocument.FormattingShowClear = False
ActiveDocument.FormattingShowParagraph = False
ActiveDocument.FormattingShowNumbering = False
End Select

MsgBox "Conversion to Format 2003 is complete. Please save and check your document.", vbExclamation + vbOKOnly

Exit Sub
End Sub
Private Sub CommandButton2_Click() 'cancel button
Unload Form2003
End Sub

this was my other attempt, it would change the font, but not the styles, so adding a new paragraph, it would resort to old style

Code:
Sub Main()
' RLH 29/1/03 Macro created to convert existing documents to new
' Format2003 style. Copies styles from attached template down to
' document and applies them. Forces some styles to certain cases.
'
Dim Template
Dim ActiveDoc
Dim Style

On Error Resume Next

If ActiveDocument.AttachedTemplate = "Agreement.dot" Then
GoTo Update
ElseIf ActiveDocument.AttachedTemplate = "Deed.dot" Then
GoTo Update
ElseIf ActiveDocument.AttachedTemplate = "Normal.dot" Then
GoTo Update
ElseIf ActiveDocument.AttachedTemplate = "Format2000.dot" Then
GoTo Update
Else
Selection.WholeStory
Selection.Font.Name = "Times New Roman"
Selection.HomeKey Unit:=wdStory
End
End If

Update:
If ActiveDocument.AttachedTemplate = "Normal.dot" Then
ActiveDocument.AttachedTemplate = "C:Program FilesMicrosoft OfficeTemplatesformat2000.dot"
End If

Template = ActiveDocument.AttachedTemplate.Path & "" & ActiveDocument.AttachedTemplate
ActiveDoc = ActiveDocument.Path & Application.PathSeparator & ActiveDocument.Name

ActiveDocument.UpdateStyles

Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With


Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Doc Title")
Selection.Find.Execute
If Selection.Find.found = True Then
Do
Selection.Range.Case = wdLowerCase
Selection.Range.Case = wdTitleWord
Selection.Find.Execute
Loop Until Selection.Find.found = False
End If

'etc etc

Selection.HomeKey Unit:=wdStory

With ActiveDocument
.UpdateStylesOnOpen = False
End With

End Sub

Window Styles (No Border)
Wht I want to do is set the style of a window (of another application) like VB's "0 - None", or to remove the window border.

Copyright © 2005-08 www.BigResource.com, All rights reserved