Microsoft Development

47K

Solutions

32K

Contributors

Most development for the Microsoft platform is done utilizing the technologies supported by the.NET framework. Other development is done using Visual Basic for Applications (VBA) for programs like Access, Excel, Word and Outlook, with PowerShell for scripting, or with SQL for large databases.

Share tech news, updates, or what's on your mind.

Sign up to Post

Man, Despair, Problem, Null, One, Binary
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
1
Microsoft Certification Exam 74-409
LVL 1
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching all errors.
4
 
LVL 51

Author Comment

by:Gustav Brock
Comment Utility
Thanks. Have a nice weekend!

/gustav
0
 
LVL 66

Expert Comment

by:Jim Horn
Comment Utility
Nice job walking through code and explaining it, and thanks for attaching examples.  Voting Yes.
0
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers for re-developing a maintained code. With this technology, a local and web copy of projects can be saved. 

How Does Version Control System Works?

A Version Control System simply allows saving multiple snapshots of single project. Say, we have a project and files of code. When we work on it for some time, we might find the need to create a safe point of it (which is S1 in the figure).

Now, if we want to work more on the same project, we can copy the code and modify it and then again create its safe point (which is S2 in the figure). And likewise, it is possible to continue modifying the project (S3) but at the same time maintain history of previous projects as well. Say, at some point of time, our project did not work well (S4). So, we have the option to go back to the previous version (S3) and get started again.

When a Git repository is created, a master branch is developed and as long as we generate safe points, the master branches are added. Now, there can be requirement of adding new features to a project that is working currently (S4). So, when one developer is busy adding features to the project (F1), another can continue to make relevant modifications and work on it (S5) and same …
10
 
LVL 2

Author Comment

by:Sofía Tomas
Comment Utility
Dear Moderator,

My article "Bitbucket vs. GitHub: Which is Right for You?" is ready for re-review. Please Check it.

Regards
0
 
LVL 2

Author Comment

by:Sofía Tomas
Comment Utility
Dear Editor,

Thanks for your reply.

Regards
0
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode? They will have you believe that Unicode requires you to use a WCHAR (wide) character type and that Unicode cannot be represented by a CHAR (narrow) character type. In fact, both of these statements are completely and utterly false. Microsoft has misled you in the most egregious way.

Before we go any further, I need to clarify some terminology that is often confused. This is especially true of Windows programmers who, quite often, mistakeningly believe that using a wide character type means they are using Unicode:

Character Set: This is a complete set of characters recognized by the computer hardware and software.

Character Encoding: This is a way of encoding a character set, generally to fit within the boundaries of a particular data type. ASCII, ANSI and UTFx are all examples of character encodings.

Character Type: This is a fundamental data type used to represent a character.

These three things are intrinsically related. The character type chosen to represent a character set will have a direct impact on the character encoding used. In C++, the normal fundamental character types are either wchar_t (wide) or char (narrow). The size of the narrow and wide types are platform dependent, although C++11 has introduced fixed sized
7
 
LVL 32

Expert Comment

by:DrDamnit
Comment Utility
"When Microsoft gets involved."

You had me at the title.

Excellent work, sir.
0
 
LVL 29

Expert Comment

by:pepr
Comment Utility
+1 ... not because it helped myself [learned via more painful way], but because the articles like that should be spread to enhance the future. It the past, it was a lot of discussion about UTF-8 being impractical "because you cannot seek to the position". Actually, languages like Python 3 show, that beginners need not to care about how it is implemented inside. A unicode character is represented by a number (as one logical unit). If the programming language gives you tool for accessing the parts of the string easily you do not want to care about how many details must be solved. You simply enjoy when it works (and you feel safe when you know it is not an ad-hoc solution with some dark corners).
0
You can go ahead and Google this
 
Set objOutlook = CreateObject("Outlook.Application")

Open in new window

It looks SO simple to fire up Outlook to do something via VBA automation.
Throw in a reference to the Microsoft Outook XX.0 library and get busy
  • Create contacts from a spreasheet or database
  • Save attachments and log what's been done.
The list is endless for WHY you'd want to automate Outlook. And so you do it, just like it looks up there in the code snippet.

And then, the first time you run that code with Outlook open, you'll get a nice Error 429
Run-time error '429': ActiveX component can't create object
 

'Well, crud!'


You'll look around on the Internet and discover that error occurs because, really, only ONE instance of Outlook is meant to be open at a time.  And so you'll remember to manually close Outlook before you run your code -- until you get sick of that. And you'll poke around a little harder at the internet and you'll find
 
Set objOutlook = GetObject(, "Outlook.Application")

Open in new window

This gets the open instance of Outlook for your use.
Excellent.
Right up until you didn't have Outlook open again.  And then you're back to 429 again
 

'Double crud!'


So, you'll growl and curse and do something like
 
On Error Resume Next
Dim objOutlook As Outlook.Application
Set objOutlook = GetObject(, "Outlook.Application")

If Err.Number = 429 Then
    Err.Clear
    Set objOutlook = CreateObject("Outlook.Application")
End If

Open in new window

And you'll pat yourself on the back for a job well done...
Until the day you come to recall exactly WHY
On Error Resume Next
2
 
LVL 66

Expert Comment

by:Jim Horn
Comment Utility
Very well laid out, and relates to a current business need.  Voting yes.
0
What is better between TextBox.Text = String.Empty and TextBox.Clear()?

From an aesthetic view, I would choose the TextBox.Clear() method, because it is logically better to clear a value, rather than re-assigning it with another value. But I wanted to do a little test...

I am working with WPF and c#, in a .NET 4 environment:
Stopwatch sw = new Stopwatch();
sw.Start();
for (Int32 i = 0; i < 1000000; i++)
    textBox_UserName.Text = String.Empty;
sw.Stop();
Int64 elapsed_StringEmpty = sw.ElapsedMilliseconds;

sw.Reset();
sw.Start();
for (Int32 i = 0; i < 1000000; i++)
    textBox_UserName.Clear();
sw.Stop();
Int64 elapsed_Clear = sw.ElapsedMilliseconds;

Open in new window

The two tests produced very different results:
1) Assign the value String.Empty to the Text property: 240 ms
2) Call the Clear() method: 10198 ms
This led me to avoid using the Clear() method which is 42 times (!!!) slower than assigning String.Empty value to the Text property.

The problem can be in part mitigated by surrounding the “Clear()” operation by a “BeginChange” / “EndChange”:
sw.Reset();
sw.Start();
 textBox_UserName.BeginChange();
 for (Int32 i = 0; i < 1000000; i++)
    textBox_UserName.Clear();
 textBox_UserName.EndChange();
 sw.Stop();
 Int64 elapsed_Clear_Change = sw.ElapsedMilliseconds;

Open in new window

In fact the same operation took now 6030 ms. It is still far from than the String.Empty assignment, but just a bit more than half the time of the previous execution.

The "Clear()" method implementation of the System.Windows.Controls.TextBox resides in the PresentationFramework.dll. If we take a look at it, then we can understand why it takes longer than the simple ".Text" assignment:

Open in new window

4
 
LVL 38

Expert Comment

by:younghv
Comment Utility
Very nicely done.
You have a nice way of presenting technical information in an easily read format.

"Yes" vote above.
0
 
LVL 13

Author Comment

by:jonnidip
Comment Utility
Thank you for reading!
0
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and other resources.

Recently I was working on a task where I was to apply themes to a Silverlight application. After doing some RnD, I created two different themes for most commonly used controls e.g. Button, TexBlock, TextBox and I was hoping that it will work straight away without any issues but I was stuck on a few points which were: loading and setting resources at run time. After spending some time on it I was able to get it running. This is where I decided to write a short article with running example of themes and dynamic loading of themes in Silverlight 4.

In this article, We will cover styling using standard as well as BasedOn approach. Let us start with standard approach where we will be creating two different themes for a TextBlock control.

Style A
    <Style x:Key="tbNormal" TargetType="TextBlock">
        <Setter Property="Margin" Value="0,0,10,0"/>
        <Setter Property="Foreground" Value="#FF000000"/>
        <Setter Property="FontFamily" Value="Arial"/>
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
    </Style>

Open in new window


Style B
    <Style x:Key="tbNormal" TargetType="TextBlock">
        <Setter Property="Margin" Value="0,0,10,0"/>
        <Setter Property="Foreground" Value="AliceBlue"></Setter>
        <Setter Property="FontFamily" Value="Arial"/>
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
    </Style>

Open in new window


The only difference between the two themes is the use of different Foreground property. Now, we can further improve the theme XAML by using BasedOn property like this:

Style A

Open in new window

0
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the WrapPanel is basically using it.

To understand Panels in general, we will need to understand 2 basic but very important functions: Measure and Arrange. Any UIElement (or Anything that derives from it) has those 2 functions.

Measure - gets a size as a parameter and returns a size as a result. This function gets the available size of the parent and returns the desired size of the element.

Arrange - gets a Rect, which is: Top, Left, Width and Height. It is not hard to understand that the caller forces the element to be located at position Top,Left... and have the size: Width, Height.

So if we are some kind of content container, like a panel, and we have children, in order to position them we only need to call Measure and Arrange for each child.


But how do I, as a Panel, know when I need to remeasure and to rearrange the elements?? For that we have MeasureOverride and ArrangeOverride :-)

Lets have a look... Open Visual Studio and create a new WPF application. It should also work on Silverlight (But instead of a Window, we will have a Page that derives from UserControl).

Now Lets add a class that will derive from a Panel. Call it: MyWrapPanel:

    public class MyWrapPanel : Panel
    {
    }

Open in new window


Now let start putting some code inside:

Open in new window

1
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared overly complex, so I decided to write my own.

Design

So, to start with I added a Silverlight UserControl to my project and named it 'CircularProgressControl', and added a Canvas control to the Layout Grid. I then added 12 ellipses and arranged them in a circle around the canvas. I then set the Fill property to a RadialGradientBrush with 3 gradient stops and modified a gradient offset of each dot to appear slightly less intense as the previous. The result looked like this...

Dot Layout
To add a little flexability to the control and allow me to easily change the base color to something other than Blue, I added some property binding, which involved 3 things.

In the code behind of the UserControl, I added a property called DotColor....
    ''' <summary>
    ''' The base color for each of the dots on the progress control
    ''' </summary>
    Public Property DotColor As Color

Open in new window

I then added property binding to each of the dots in the control, so this....
            <Ellipse StrokeThickness="0" Width="15" Height="15" Canvas.Left="30" Canvas.Top="0" Name="Ellipse1">
                <Ellipse.Fill>
                    <RadialGradientBrush>
               

Open in new window

4
 
LVL 2

Expert Comment

by:baskar_ram
Comment Utility
Nice control... The BusyIndicator control in the below url also so good..
http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html
0
 
LVL 47

Author Comment

by:Wayne Taylor (webtubbs)
Comment Utility
The BusyIndicator is good, and that was what I settled with for a while. But, it's not circular :)
0
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\Start" from 3 to 4. This procedure is also used by many system admins to disable USB ports within their purview to prevent corporate employees from coping sensitive corporate data. However keyboard interface devices cannot be disabled. The only way to disable them is through BIOS.

There are many devices like Barcode scanner, Magnetic card readers etc. which use the USB port to send data to the computer. Since these devices use the keyboard interface (act like a keyboard), it is by design that MS windows will not allow them to be disabled. However it sometimes is very crucial for an application developer to control these devices. Thus disabling the USB port from BIOS is not at all an agreeable solution. Windows uses messaging system to send events to applications. Messages like key down, key up etc are send by windows to the active window's application. If the application which is intended to receive data is not the active window, data from these kind of devices will fail to reach the application. Thus the application will fail to behave as intended.

The solution to the problem is to write a global keyboard hook. With a global keyboard hook immaterial of the application having the …
0
 
LVL 9

Author Comment

by:expert_tanmay
Comment Utility
Hi stone5150,
Thanks
0
Want Experts Exchange at your fingertips?
LVL 9
Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it.

My software Visual Studio 2008 crystal report v11

My issue was I wanted to add crystal report to a form and show a report of what the user had added to a listbox.  Without making the user(s) select all of them  in the listbox. Unless you directly select the items in the listbox there no way to go though them that I have found listed on the web.   I found a way to process all items in a listbox without making a user select them.

I have a project where I create a form with 2 listbox, a textbox, a rich text box. We load the first textbox with a list of reasons for our clients to be rejected for an application. Since each client reasons can be different we have a flexible way to keep up to date.

We have a master list we load into listbox1. Each of the reasons has a text description with it. The user selects from listbox1 and it gets added to listbox2. I set it so when the user double clicks on a reason in listbox1 its gets add to listbox2.  The description appears in the richtextbox and can be changed.  We have a crystal report  attached to the form to show the letter we will send.  

The problem I was having was after my user builds listbox2 there is not an easy way to select all the reasons the user added in listbox2. We don’t want to explain that to create the letter the user has to select all the added reasons in listbox2. I have …
0
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usually needs to be configurable. Putting this information within the code makes it rather rigid as changing this at the time of implementation would mean recompiling your entire assembly. Due to this, most applications tend to use configuration settings for such dynamic parameters.

One of the ways of passing configuration values to the Silverlight application is through “initParams” but this can become quite tricky especially when the number of settings is more or if your settings are in the form of layered objects. Imagine if you need to make around 5 parameters configurable (Name,Age,Sex,Country and Location),your initParams would look something like this: “Name=Gautham,Age=26,Sex=Male,Country=India,Location=Bangalore”. Slightly clumsy. Now, imagine if each of these is a complex layered object. Very clumsy, right?

An alternative I find very useful is to use a xaml file to do this. The concept is similar to having a web configuration file for your asp.net application, wherein your configuration file resides in your root web site. I am going to explain this with the help of a small example using c# code, visual studio 2008 as IDE and Silverlight 3.0.

To begin with, let’s create a normal silver light application and a web …
0
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls for several of my UI requirements and find that they are quite easy to use once you get the hang of it. However, the controls can seem a little confusing and hard to use for a beginner, especially if you have a background only in winforms. It is much easier if you try to work with individual controls and understand their behavior in the beginning stages.

When I started off with WPF, I needed to show a recursive object in a tree view and frankly speaking, the WPF Treeview control gave me nightmares while I tried to do so .However, in the end it turned out to be pretty simple. All you need to do is create a data object that you want to show on the tree and bind it to the itemsource of the Treeview. Here’s how.

Data Object

Let us create a class called Person with Name, Age and Children as properties. The aim here is to show the name and age of a person in a tree along with details of his children as sub-nodes and this continues recursively, similar to a family tree.
 
public class Person
    {
        public Person()
        {
            Children = new ObservableCollection<Person>();
        }
        public string Name { get; set; }
        public int Age { get; set; }
        public ObservableCollection<Person>

Open in new window

0
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decoding is usually done — and finally, I'll provide several examples of C++ source code, including a function that decodes base64 nearly ten times faster than commonly-used functions.


What is Base64?

Base64 is a way to represent binary data in a way that avoids some of the problems associated with binary data.  When you handle binary data, you need to take special care about embedded nulls, commas, quotes, apostrophes, the less-than, ampersand, and space characters, and so forth.  Base64 data, on the other hand, is simple text; you can assign it to a string data type, copy it, scan, and transfer it without worries.

You may see base64-encoded data in emails and in XML CDATA sections. If you have ever worked with HTTP headers, you have probably seen:
Content-Type: application/x-www-form-urlencoded
Authorization: Basic TXlVc2VySUQ6TXlQYXNzd29yZA==

Open in new window

The text after the word, Basic is a base64-encoding of a username and password (specifically, that string encodes MyUserName:MyPassword).

You may see base64 used to transport encrypted data, which often contains such otherwise "awkward" characters.  In an earlier article, Easy String Encryption Using CryptoAPI in C++, I recommended converting encrypted data to hexadecimal
5
 
LVL 49

Author Comment

by:DanRollins
Comment Utility
Thanks!
You have my permission to use the code in any way you want.
-- Dan
0
 
LVL 3

Expert Comment

by:mrfreshly
Comment Utility
Hi Dan,

Love the article.  

I'm doing some MSVC++ coding and thought I'd try your Base64Fast functions out.  

The first string I tried to encode was "encode me!" (10 bytes) which yielded "ZW5jb2RlIG1lIQ==".  But then when I passed that back into the decode function it returns 12 bytes "encode me!¿p".

I tried "hello world!" which encoded to "aGVsbG8gd29ybGQh" and decoded back to "hello world!" perfectly.

I tried a four letter word and it came back with 6 after the decode that looked similar to other extra non-alpha characters.  So, 4 character and 10 character sources seem to be causing a problem.

I tested the "ZW5jb2RlIG1lIQ==" string via the web based decoder and it decoded correctly.  There must be a gotcha in the FromBase64Fast code.  I'll update if/when I figure it out.

Update:


The condition of b2 or b3 being 99 never triggered when the "=" pad came up.  My solution is a total hack but it seems to work for now, I'll update again with something sexier later.

Until then, consider these changes to the last section of code for "FromBase64Fast":
		if ((pwSrc[1] & 0x00FF)!=0x003D)  {
		//if (b2 != 99)  {
			if (nLenOut >= nLenDst)   return(0); // error
			*pDst++ = b2;  nLenOut++;
			if ((pwSrc[1] & 0xFF00)!=0x3D00)  {
		//		if (b3 != 99) {
				if (nLenOut >= nLenDst)   return(0); // error
				*pDst++ = b3;  nLenOut++;
			}
		}
//	*pDst = 0; // could terminate with NULL, here
	return(nLenOut);
}

Open in new window

I ran some generated data through it and it matched the results correctly.  More testing is needed, but so far so good.

Cheers,
Chris
0
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be coding in C++ in Visual Studio.

This seems like it would be a trivial problem, and indeed, it turns out to be relatively easy.  The difficulty is in wading through the zlib documentation and figuring out what not to do!  As with most GNU projects, the documentation is written in some sort of unix-geek-speak, and for some reason, they included lots of special options and rarely-needed functionality, but failed to provide a simple function call to handle this most basic of needs.

To get started, you will need to download the pre-built zlib DLL.  The zlib main page is here:
       http://www.winimage.com/zLibDll/index.html
and the direct link ot the ZIP file containing the DLL is here:
       http://www.winimage.com/zLibDll/zlib125dll.zip

It would be way too easy for us if the zlib geniuses had provided the needed C++ header files with the download, so you also need to download the source for the entire library (if I may make an editorial comment here: Sheesh!).  Get the ZIP file of the entire library source code here:
       http://zlib.net/zlib125.zip
We won't be building the library, but you will need to get the two files:
       zlib.h
and
       zconf.h
and put them into your project directory.

2
 

Expert Comment

by:marikcool
Comment Utility
Qlermo inflateEnd and  deflateEnd
0
 
LVL 70

Expert Comment

by:Qlemo
Comment Utility
I know. I just expect someone posting with "rtfm" to take more care of being precise and correct.
0
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code.
GUI version illustrates the conversionAlthough RTF is coming to be considered a "legacy" format, it is still in common use... possibly because of the ease with which a programmer can drop a Rich Edit control onto a form and allow the user to set fonts, colors, text formatting and even embed objects such as pictures and tables.  Also, Windows comes with (and always has, and probably always will come with) the WordPad application program for creating, viewing and modifying RTF data.

But HTML is the lingua franca of the day, especially for email communications.  

Anyway, it's not unusual to have an RTF file and need a way to generate HTML from it.  Office Word automation can do that pretty easily, but one can't be certain that Word will be available on your customer's computer.

There are some utility programs out there that try to convert the RTF tokens directly into HTML, but they are usually very limited; they tend to fail when the RTF data is at all complex (e.g., they can make text bold or italics, but that's about all).

An Easier Easy Way?

In searching for a simple, clean solution, I noticed that WordPad was easily able to convert HTML fragments (e.g., as Crl+C copied from a browser) into RTF.  I wondered if the reverse was true... Could I paste RTF from the clipboard into an HTML editor window?

2
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon.

The tool is part of VSTO 2008 Power Tools.  The VSTO 2008 Power Tools can be downloaded from:
http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&displaylang=en
 
The VSTO_PTRibbonIDs.exe installs the Ribbon IDs Tool Window.  After installation, a new "ImageMso Window" item is added on the Tools menu of VS2008 as shown in figure 1.
 VS2008 Tools menuFigure 1. VS2008 Tools menu.

To assign the built-in Office icons to the ribbon button, follow these steps:

1.  On the ribbon designer, select an existing button, or create a new one by dragging it from the toolbox to the ribbon.

2.  On the VS2008 Tools menu, click "ImageMso Window" to display "Image Mso" dialog box.  The dialog box will look like figure 2.
Initial Mso dialog boxFigure 2. Initial Mso dialog box.

3.  In the tool window, type "saveas" in the search box, and click the magnifying glass.  The window will change to show just the related icons (see figure 3) .

VSTO Ribbon IDs Tool WindowFigure 3. VSTO Ribbon IDs Tool Window showing the search results for save.

4.  Any buttons that contains the word "saveas" in the id name will be displayed.  Notice that if you hover over a button, the tool tip …
1
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the process.  

This article describes how to write short scripts that will let you "pull the strings" on an application program to make it dance to your will.  Examples will be in JavaScript code (.JS files) but the concepts here also apply to VBScript (.VBS files), in case BASIC is your language of choice.

Before running the SendKeys script...after double-clicking the toPng128.JS icon...After running the SendKeys scriptHere are some example usages:

You need to go through a directory of images files and convert them from BMP to JPG, using only MsPaint.
You need to look at each of a series of text files and for each one, you must decide to either keep it, delete it, or move it to a different directory.  Your viewing tool is Notepad.Exe
You need to copy some text from one program and paste it into another, again and again.
In short, this technique is handy anytime that you can accomplish some individual task with a few keystrokes but you would rather not spend the rest of the day stroking those particular keys over and over.

Important Notes:

The SendKeys function is often said to be somewhat "flaky" and "unreliable" and I would not recommend using it for any sort of mission-critical operation.
In particular, you must be careful to use AppActivate()
9
 
LVL 18

Expert Comment

by:Ravi Agrawal
Comment Utility
Thanks for writing.
0
 
LVL 10

Expert Comment

by:etech0
Comment Utility
I like Perfect Macro Recorder - does the trick without the code

http://www.perfectiontools.com/index.html?fra=http://www.perfectiontools.com/downloads.html

It's not free, but I got it for free from GiveawayOfTheDay, so anyone who's not in a rush can keep checking their site 'til it comes around again.

http://www.giveawayoftheday.com/
0
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article, we saw how to put the Delete button back there where it belongs.  "Delete" is a predefined action, but today, we're going to add a button that you can program to do whatever you want.
Custom button "MyTool" added to the Win7 toolbarMicrosoft intentionally left out the familiar "Customize..." option for the Explorer toolbar.  They provided a bunch of pre-set toolbars that depend upon the types of files that are in the folder that is being displayed.  In any case, they do not (yet) document how to tweak the registry to modify those preset layouts.  However, there are enough examples in the existing registry entries to make it possible to do some nifty tweaks without resorting to low-level system programming.

As before, we'll be working with the subkey(s) under the registry key:

    HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes

In there, you'll find a bunch of GUID items that associate with various types of folders.  See part one for more details.  We'll again be working with the item that represents "Generic" folder data.  This basically means all folders that are not "optimized" as being a "Photo" folder or a "Document" folder or any of the special Shell Namespace folders; that is, it appears above folders that are set to display "General Items."

[step="" title=""]Notice:
10
 
LVL 60

Expert Comment

by:Kevin Cross
Comment Utility
Windows Programming Forum (Question and Answer Topic Area)
http://www.experts-exchange.com/Programming/System/Windows__Programming/
0
 
LVL 49

Author Comment

by:DanRollins
Comment Utility
I got an email regarding this article from a person who neglected to provide his EE member name...  It suggested that a valuable custom tool would be one that might be called "Add Folder"  

The current mechanism involves: right-click / New... / Folder / type something to rename from "New Folder"  (that is, a multiple-step operation).  The custom tool would pop up a box to input the folder name and it could set folder attributes and even open a new Explorer window on the folder for immediate use.

It's a good idea.  If you have other ideas for useful custom tools, feel free to post them here.

-- Dan
0
MS Dynamics Made Instantly Simpler
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper.

If your program provides printed output, you may want to be able to preset some settings for automatic printing so that your user does not need to monkey around in the "Preferences" or "Advanced" settings of the common printing dialog.  For instance, in one of my application programs, I let the user select a certain type of wide-format report, and when it came time to print that report, the program would force a small font and preset for Landscape output.  

The Pages per Sheet setting, sometimes called N-up printing, lets your user conserve paper by shrinking the page and printing two pages side-by-side.  I've found that the text in 2-up printing, though small, is still readable.  If your eyes are good (or the text is rendered in a large font), even 4-up printing is usually viable.  I often use it for C++ source code printing.
6-up printing of a five-page fileBeyond that, Windows actually lets you select 6-, 9- and 16-up printing.  Though the output is usually too small to be readable, this option could be used in a "pre-print" run of a long document... each page on the sheet would act as a sort of thumbnail image to help identify gross formatting problems, "widows and orphans," and other printing artifacts that you would like to avoid before …
2
 

Expert Comment

by:mccoymad
Comment Utility
I do not obtain to read the code!
0
 
LVL 5

Expert Comment

by:rberke
Comment Utility
vba code can be found at

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_27427865.html#a37115656

call printanywhere("n4d") will print  4up duplex (word or excel document) to a printer named "North". Tested with office 2003 under windows 7 pro.
0
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.
The DropTarget gadgetIn previous articles, Create a Win7 Gadget and Create a Win7 Maze Gadget, we covered the basics of creating a Windows 7/Vista gadget -- a small application program with an HTML U/I that you can drag from the Win7 Gadget Gallery and drop onto your desktop.  Please read those two articles to see how to get started creating your own gadgets.

Gadgets are easy to write, in either JScript or VB Script, and they can use ActiveX objects, as well as a special set of gadget tools, so they are powerful and flexible.  And, let's face it, they are cute.

Transparency
First, let's look at how to make a completely transparent gadget.  The trick is to use the g:background tag.   Gadgets run in a special process, sidebar.exe, that provides the HTML rendering and script support.  It gets to look for its own namespaces and process them in special ways.  The g: namespace includes g:background, g:image, and g:text.

g:background is a property of the body element in your HTML.  It sets the background, but in addition to the regular things you can do with a document.background, it supports a few more methods and attributes.  The following is a complete gadget implementation (you would need only write gadget.xml as described here):

Open in new window

0
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel to fit its contents, how to use an ActiveX object in a gadget, and how to use the System.Shell.chooseFile method.
A Gadget with a Flyout PanelIn a previous article, Create a Win7 Gadget, we covered the basics of creating a Windows 7/Vista gadget -- a small application program with an HTML U/I that you can drag from the Win7 Gadget Gallery and drop onto your desktop.  Please read that article, and those listed in the References section below, for background information.  

Flyout Panel
To add a flyout panel, you need only add a line like this to your gadget's main HTML file script:
System.Gadget.Flyout.file = "MyFlyout.html";

Open in new window

The HTML for the flyout panel is nothing special... any collection of input items and display areas.  You will need to provide the script code to support the functionality you want, and you'll most often want to provide an onload handler to run code that should be executed when the flyout opens.

Triggering the Flyout
Unlike with the settings-box handling that we worked with here, the system does not provide a gadget toolbar control to open the flyout.  You must provide a triggering mechanism yourself -- a click, a mouse roll-over, or other activity.  To open the flyout, use code like:
System.Gadget.Flyout.show= true;

Open in new window

3
 
LVL 49

Author Comment

by:DanRollins
Comment Utility
Rename the attached .ZIP file with an extension of .GADGET and then double-click

Note that this is just a tutorial example and you are expected to make changes (for instance, it expects to see a particular file:  c:\temp\test.doc)

-- Dan
FlyoutTest.zip
0
 

Expert Comment

by:MIKYY
Comment Utility
it is really nice.
thanx a lot Dan.. really really really thank you...
0
This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista.  Gadgets can be dropped anywhere on the desktop to provide instant information, or to act as a gateway to a website or a larger program.  

What I like about gadgets is that they are really just small HTML pages.  That means:  No big-project development overhead.  If you have Notepad.exe and some knowledge about HTML, then you can write your own gadget.  Like HTAs, they run with with full local-program privileges, and can use ActiveX objects.  There is no limit to the creative things you can do with gadgets.Fig. 1-1:  Win7 gadgets!
How to Create a Gadget (the short version):
Here's all you need to do to create your own gadget:

1) Write an HTML page, say gadgetName.html

2) Write a short XML file, named (exactly) gadget.xml

3) Copy these two files into a particular directory:
   userDir \ AppData\Local\Microsoft\Windows Sidebar\Gadgets\ gadgetName.gadget

The Details:
Follow these steps and you'll have a new gadget in a few minutes:

1

Create a new folder on your desktop and name it
HelloGadget.gadget

2

Open that folder and create two files in that folder.  Here's the XML file (called a manifest):

gadget.xml
<?xml version="1.0" encoding="utf-8" ?>
<gadget>
  

Open in new window

26
 
LVL 49

Author Comment

by:DanRollins
Comment Utility
Please refer to the three related articles listed above (under the heading "Up Next").  A gadget can respond to user-interface events such as keystrokes, clicks, item drops, and rollovers, and to timer events (basically anything that can be sensed in a web page), plus whatever functionality you can add by using activeX objects such as the FileSystemObject.
0
 

Expert Comment

by:saumil11
Comment Utility
@dansrollins thanks u made my day
0
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  It includes the complete source code for a Win7 gadget that creates and solves mazes -- endlessly soaking up some of those extra CPU cycles.
The Maze! gadget with settings panelFor introductory information -- a getting started guide -- see:

    Create a Win7 Gadget

Gadget Attributes
In the Gadget Gallery, the "Show Details" button lets you see various facts about the gadget -- copyright, who wrote it and so forth.  These are all set by what you put in the XML file that is in your gadget folder.  For instance, our "Hello World" gadget from the previous article shows the bare minimum:
Bare-bones "details panel"Our next gadget will populate more fields of the XML file.  Here's the code:

...\Gadgets\Maze\gadget.xml
<?xml version="1.0" encoding="utf-8" ?>
<gadget>
  <name>Maze! Gadget</name>
  <version>1.0.0.1</version>
  <author name="Written by Dan Rollins">
    <info url="DanRollins.com" />
    <logo src="DanRollins.jpg" />
  </author>
  <copyright>&#169; 2009 by Dan Rollins</copyright>
  <description>Maze! Gadget.
An amazing gadget of incredible complexity, brought to you by the same people who produced 

Open in new window

6
 

Expert Comment

by:MIKYY
Comment Utility
I am not getting the maze on my desktop instead there appears a small white reactangle. In the options menu of gadget ,i am getting a pop up window that says height and width.but still there is no maze ,only a small white box  is appearing.I have made this just like as u have suggested HelloGadget,by putting all the html ,xml and javascript files in one new folder (maze.gadget) in C:/program files/windows Sidebar/ Gadgets.Now plese help me out in this situation.
0
 
LVL 49

Author Comment

by:DanRollins
Comment Utility
Hi MIKYY
Is it possible that sidebar gadgets have been disabled on your system?  See this link for related information.  If that is not the case, I suggest that you try the "getting started" gadget in my earier article here, and see if that one works on your system.
0
Preface

The task was to make a window with an image as the window background and do not stretch this image.

The first proposed solution was really simple:
1. Load the image.
2. Detect its size.
3. Create a window with the WS_POPUP style.
4. Set the window size exactly as the loaded image.

For example, if the image has width cx and height cy, the following function will calculate the rectangle in the center of the desktop for my window:

BOOL Calculate(int cx, int cy, RECT& rect)
{
	HDC hDC = ::GetDC(NULL);
	const int w = GetDeviceCaps(hDC, HORZRES);
	const int h = GetDeviceCaps(hDC, VERTRES);
	::ReleaseDC(NULL, hDC);

	rect.left = (w >> 1) - (cx >> 1);
	rect.top = (h >> 1) - (cy >> 1);
	rect.right = rect.left + cx;
	rect.bottom = rect.top + cy;

	return TRUE;
}

Open in new window

Note: the full source code demonstrating the solution is in the Appendix.

My colleagues said, "It will be great, if it will be possible to move this window."
It's not that easy. But it was solved too (handling of WM_LBUTTONDOWN, WM_MOUSEMOVE and WM_LBUTTONUP messages).

The next request was to make the window resizable.
 - Oh! But you said in the beginning do not stretch the image!
 - Yes. But, but now we see that it will good to resize the window in a predefined range.

Ok. Let's make the window. Now, with the standard styles, it should be the main application window - "sizeable" and "movable".

GetWindowRect with GetClientRect

The question is how set the window size so, that the client rectangle will be exactly as the image size drawn on it?

The window has a frame, a caption, maybe, a menu. GetWindowRect function retrieves the size of the whole window including these attributes. GetClientRect
0

Microsoft Development

47K

Solutions

32K

Contributors

Most development for the Microsoft platform is done utilizing the technologies supported by the.NET framework. Other development is done using Visual Basic for Applications (VBA) for programs like Access, Excel, Word and Outlook, with PowerShell for scripting, or with SQL for large databases.