|
|
I seriously doubt anyone is going to install software on their machine just to use your Internet Cafe. Your better bet is to use a firewall that already does this for you. What do you think corporations use?
On top of that, you've got a nightmare of a job trying to figure out what a "good" address is and what a "bad" one is.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Greetings,
I am using the PlaySound methode as specified below.
However, It always defaults to the default windows sound
regardless of where I place the file and the path I specify.
Here's the code snippit:
ussing System.Runtime.InteropServices;
namespace MySound {
public class Sound {
[DllImport("winmm.dll")]
public static extern bool PlaySound(string filename,long hmodule, int dword );
// To play the sound, I use:
Sound.PlaySound("BorderLine.wav",0,0x0001|0x0002|0x00020000);
Thanks,
--
Magela
|
|
|
|
|
This site has good info on working out proper pinvoke calls, and the URL is to the page on PlaySound.
http://www.pinvoke.net/default.aspx/winmm/PlaySound.html[^]
Also, is BorderLine.wav in the same folder as your exe ? Have you tried a full path ? Either way, there is another problem, as 2 is the flag to not play the default sound.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Your problem is that the second parameter should be declared as an IntPtr , which is a 32-bit integer in 32-bit Windows and a 64-bit integer under 64-bit Windows (not under the WOW64 subsystem). This is the size of a pointer, which an HMODULE (in the native declaration) is.
A long (System.Int64 ) is always 64 bits. So, unless this only runs on 64-bit Windows as a 64-bit application (support for which starts in .NET 2.0 when compiled with the right flags) your parameters are pushed onto the stack (or into registers, since .NET uses FastCall by default) incorrectly. The third parameter would always be zero because the low-order bits would not be read by the callee (PlaySound ).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Good day all.
I have a two column Listview. The first column I would like to make readonly (I do not want the user to make changes to the content). The second column (Listviewitem sub) I would like the user to be able to make modification to it contents. Has anyone experienced or have written code to handle this type of solution.
Thank you in advance for you assistance.
|
|
|
|
|
That is not the best solution ,but it's easier,You can make your control a data grid,an make teh row read only and the other not,it will be likely for you.
|
|
|
|
|
My advise is that you look into Property Grid. Just do a search here in codeproject for "Property Grid" and you will find plenty of good examples. However; if you insist on using ListView, you will probably have to override the OnPaint event and place a textbox on top of the text you need to edit.
|
|
|
|
|
You might want to take a look at this article[^]
Regards,
mav
|
|
|
|
|
Hey Mav thanks. This is exactly the functionality that I am seeking since I can not find any documentation on editing a subitem other that setting the FullRollSelect property of the ListView.
You have done a great job with the extension of the ListView.
|
|
|
|
|
I recently discovered code for extending the RichTextBox to allow for a Background color on a selection, which is exactly what I neeed. However I am having some problems dealing with the Select/Selection properties. It seems that as soon as I append text to the RichTextBox the entire thing inherits the colors of the last SelectionBackColor given. Here is some sample code:
public class ExtendedRichTextBox : RichTextBox<br />
{<br />
#region Fields<br />
private const int EM_SETCHARFORMAT = 1092;<br />
private const int EM_GETCHARFORMAT = 1082;<br />
private const int CFM_BACKCOLOR = 67108864;<br />
private const int SCF_SELECTION = 1;<br />
<br />
[StructLayout( LayoutKind.Sequential )]<br />
private struct CHARFORMAT<br />
{<br />
public int cbSize;<br />
public uint dwMask;<br />
public uint dwEffects;<br />
public int yHeight;<br />
public int yOffset;<br />
public int crTextColor;<br />
public byte bCharSet;<br />
public byte bPitchAndFamily;<br />
[MarshalAs( UnmanagedType.ByValArray, SizeConst = 32 )]<br />
public char[] szFaceName;<br />
<br />
public short wWeight;<br />
public short sSpacing;<br />
public int crBackColor;<br />
public int LCID;<br />
public uint dwReserved;<br />
public short sStyle;<br />
public short wKerning;<br />
public byte bUnderlineType;<br />
public byte bAnimation;<br />
public byte bRevAuthor;<br />
}<br />
<br />
[DllImport( "user32", CharSet = CharSet.Auto )]<br />
private static extern int SendMessage( HandleRef hWnd, int msg,<br />
int wParam, ref CHARFORMAT lp );<br />
#endregion<br />
<br />
#region Constructors<br />
public ExtendedRichTextBox() <br />
{<br />
}<br />
#endregion<br />
<br />
public Color SelectionBackColor<br />
{<br />
get<br />
{<br />
CHARFORMAT fmt = new CHARFORMAT();<br />
fmt.cbSize = Marshal.SizeOf( fmt );<br />
<br />
SendMessage( new HandleRef( this, Handle ), EM_GETCHARFORMAT,<br />
SCF_SELECTION, ref fmt );<br />
<br />
if ( ( fmt.dwMask & CFM_BACKCOLOR ) == 0 )<br />
return Color.Empty;<br />
<br />
int backCol = fmt.crBackColor;<br />
Color ret = ColorTranslator.FromWin32( backCol );<br />
<br />
return ret;<br />
}<br />
<br />
set<br />
{<br />
CHARFORMAT fmt = new CHARFORMAT();<br />
fmt.cbSize = Marshal.SizeOf( fmt );<br />
fmt.dwMask = CFM_BACKCOLOR;<br />
<br />
fmt.crBackColor = ColorTranslator.ToWin32( value );<br />
<br />
SendMessage( new HandleRef( this, Handle ), EM_SETCHARFORMAT,<br />
SCF_SELECTION, ref fmt );<br />
}<br />
}<br />
public void AppendText(String text,Color backcolor,Color color,Font font) <br />
{<br />
int len = this.Text.Length;<br />
this.Text += text;<br />
this.Select(len,text.Length-1);<br />
this.SelectionBackColor = backcolor;<br />
this.SelectionColor = color;<br />
this.SelectionFont = font;<br />
}<br />
}
I don't quite know what the problem is and moreover how the Selection properties really work. Anyone have any insight? Thanks.
|
|
|
|
|
|
Hi,
I´m trying to automate Microsoft Access from Microsoft Visual C# .NET with the following code. My problem is that all that is showed is an Access Window and not my
Access report. Can anyone tell me what I do wrong?
Access.Application oAccess = null;
oAccess = new Access.ApplicationClass();
oAccess.OpenCurrentDatabase(
"c:\\InvoiceDB.mdb", //filepath
false,null
);
//View report InvoiceFoundation
oAccess.DoCmd.OpenReport(
"InvoiceFoundation", //ReportName
Access.AcView.acViewPreview, //View
System.Reflection.Missing.Value, //FilterName
System.Reflection.Missing.Value,
Access.AcWindowMode.acWindowNormal,
System.Reflection.Missing.Value//WhereCondition
);
oAccess.Visible=true;
oAccess.CloseCurrentDatabase();
THX in advance
Thomas Andersson
|
|
|
|
|
Hi!
I want to marshall a struct with 2 different char sets one Unicode and one Ansi.
This constellation doesn't work, because the CharSet.Unicode defines the char set for both types.
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public class MOUNT_STRUCT
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]
public string wszVolume;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=65)]
public string wszVolume2;
}
The next one doesn't worke too:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public class MOUNT_STRUCT
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]
public string wszVolume;
[MarshalAs(UnmanagedType.LPStr, SizeConst=65)]
public string wszVolume2;
}
how can i define 2 different charsets for one struct.
I tried several other options, which didn't work.
Is there no solution?
|
|
|
|
|
I'm not quite sure how to ask this or if it's even possible.
I know windows has some sort of basic drag and drop events that different programs use to automatically open their respective types of files (i.e. .doc files dragged onto MS. Word etc.)
now my question is say i want to trap the windows messages for the drag-drop event of the MS. Word program from an external program (it's probably going to be a windows service) to get say the file name being loaded.
I have used spy++ to try and look through the messages created for different programs when i drag and drop files to them but i'm not even sure which message i need to be looking at or even where to start.
to give you an example of what i basically want to do:
the window service would periodically monitor a program or programs such a word or paintshop when a windows message for a file drop is sent the service finds the file name and extension and either pops up an error dialog or automatically opens it in the correct program.
Hope to hear from someone on this sooner or later
p.s. if it's completely imposible to do tell me too so i don't waste my time with this
thanks
Ryan
|
|
|
|
|
The only way to do this is to hook the applications message loop. I believe that's possible in C++, I doubt it's possible in C#
There's an article on CP about Minesweeper ( the game ). I believe the author hooks into Minesweeper and adds new menu options. He is probably hooking the event loop, so it could be worth checking out. Just search for Minesweeper, how many articles could there be ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I could not find any specifc info on the site for the issue I am trying to solve, so I hope someone here has some ideas. I am working with some code created to run test suites and setup scripts. One part of the system installs an agent onto a client PC. I need to find a way to pass command line options to the msi installer UI so that the installation can be run silently. MSI installers have the necessary options to run silently, but so far I have not found a way to pass options from the command line to the UI so that several dialog boxes can be filled without having to get input from a user. Has anyone here run into this and managed to come up with a solution?
|
|
|
|
|
Here is the documentation of MSIEXEC's command line options: MSIEXEC on MSDN[^]
To give additional values for global properties you have to put them at the end of your call to msiexec in the form:
msiexec /i Sample.msi PROPERTY=VALUE
Regards,
mav
|
|
|
|
|
mav,
I have found the particular documentation you have referenced, and have spent several hours reading it and trying the above syntax. However, it appears that there is no way to link the properties on the UI dialogs and the Property table in the msi database. I have used Orca to look at the database and none of the properties from the UI dialogs are present except for one entry for the each of the edit controls (EDITB1 through EDITB4). Each of these entries are global (all upper case), but do not seem to be connected to anything that actually displays on the UI. They all have a value of 1, but changing that using the above syntax does not do anything - at least that I can determine.
I know the syntax works, because I can set things like TARGETDIR and see the change in the dialog when it is displayed.
|
|
|
|
|
I know it can be a bit confusing, but just try the following:
In your setup project, add a user dialog with textboxes.
Then set Edit1Property to TEST1 and Edit1Value to [TEST1] .
When you build and run your setup, the user dialog will pop up and there will be no entry in the first textbox.
If you call your setup using
msiexec /i mysetup.msi TEST1=ThisIsATest
then the first textbox will show ThisIsATest instead.
Regards,
mav
|
|
|
|
|
mav,
Thanks a bunch. The missing piece of the puzzle (which I found nowhere in the docs I read) is this:
'Then set Edit1Property to TEST1 and Edit1Value to [TEST1]'
A most critical bit of information and much appreciated!
|
|
|
|
|
mav,
Thanks a bunch. The missing piece of the puzzle (which I found nowhere in the docs I read) is this:
'Then set Edit1Property to TEST1 and Edit1Value to [TEST1]'
A most critical bit of information and much appreciated!
|
|
|
|
|
mav,
I have another question regarding passing in Property values from the command line.
The dialog has two properties. One is normally blank and the method you describe works perfectly to set it from the command line during a silent install. The second property has a default value that one might wish to set to a non-default value from the command line during a silent install.
Now, it seems that one must somehow use the MsiSetProperty method in a custom action that checks to see if the passed in value of the property is a null string, and if so, sets it to the default value. It also seems that one would have to write a custom dll to do this, and link it properly in the custom actions editor in the deployment project. Is this the correct way to accomplish this or is there something simpler?
|
|
|
|
|
Mav, thanks for sharing this information - it was very helpful in understanding how to pass a command line parameter to the Installer and see that value show up on a text field. I have a question though, how can I programatically detect that I didn't get a command line parameter and populate those text fields another way? Perhaps I read the registry or a text file. I want to handle the situation where I prompted a user for something during the first install, and subsequent installs I show them the previous value and allow them to change it - unless I get a command line argument - which trumps this logic.
Thanks again for sharing the information though...very helpful. -Ron
|
|
|
|
|
Does anyone have any links to example code for (any language, but prefer .net something) using Microsoft Live Communications Server? I have been reading the msdn info, but haven't found sample code for a simple app. I just want to set up a small messaging window embedded in a help desk tool. It doesn't have to be fancy, just queue messages to the help desk, and allow simple text messages to be typed back and forth like a chat app, but without all the fancy features.
An alternative would be a way to embed a windows messenger pane in a .net app.
Thanks for any info you can point me to.
|
|
|
|