|
cool. this works, something like:
<br />
public Bitmap ConvertTo256Bmp(Bitmap source_bmp)<br />
{<br />
if (source_bmp == null)<br />
return null;<br />
System.IO.Stream bmpStream = new System.IO.MemoryStream();<br />
Bitmap dest_bmp = null; <br />
try<br />
{<br />
source_bmp.Save(bmpStream,<br />
System.Drawing.Imaging.ImageFormat.Gif);<br />
dest_bmp = new Bitmap(bmpStream);<br />
}<br />
catch(Exception e)<br />
{<br />
Console.WriteLine(e.Message);<br />
return null;<br />
}<br />
return dest_bmp;<br />
}<br />
this returns a bmp with Format8bppIndexed pixel format.
only thing is, the resulting bmp, when written to disk, is much larger than the original. But that's somebody else problem ?
|
|
|
|
|
thanks for your suggestion. i can learn lot from your discussion.
|
|
|
|
|
Can some one help me out with this C++ line of code, im trying to convert it to C#, im lost on the ** ? i look on the SDK and nothing
HRESULT CreateSession([out,retval] IMediaStatusSession** MediaStatusSession);
Parameters
MediaStatusSession
[out] Address of a variable that receives the IMediaStatusSession interface pointer.
modified 16-May-21 21:01pm.
|
|
|
|
|
If I undestand it correctly , for [out] , you should use ref in C#.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
Furthermore you also need to define the IMediaStatusSession interface in you code. If this is a standalone method from a static DLL. But something tells me this line of code is from an IDL declaration of a COM object, in that case you just create a Runtime Callable Wrapper (RCW) with tlbimp and it will take care of converting all you interfaces and methods for you.
|
|
|
|
|
I tired TlBimp but i "ehmediastatus.idl is not a valid type library" Below is whats in the ehmediastatus.idl from microsoft. So i been trying to convert this idl in C#. IS there something im missing or doing wrong when using TlBimp?
// Properties in mediastatusproperty tuples represent new state information. The driver will receive a
// vector (MEDIASTATUSPROPARRAY) of MEDIASTATUSPROPERTY tuples. The driver needs to examine the property
// vector as a whole and decide what display changes are needed in order to present the new state on the
// annunciator display. The driver needs to decide what old information should be invalidated (for
// instance, turning off the FF indicator when REW is turned on. The driver has a lot of freedom to
// determine decay-time for OSDs and when to hide, flash, brighten, or otherwise highlight information.
// No display will have all these fields. They're laid out in this detail so that drivers can make intelligent
// decisions about what to display and how. Some status (like power, hd activity, IR activity, etc)
// are purposely omitted here. These really need to be driven directly via hardware interconnect.
typedef enum MEDIASTATUSPROPERTYTAG {
MSPROPTAG_Unknown = 0,
// These are of type VT_I4, but the value is that of another property. These properties
// can be used to modify the display of an annunciator element
// States and actions
MSPROPTAG_Mute = 0x1000,
MSPROPTAG_Play,
MSPROPTAG_Pause,
MSPROPTAG_Stop,
MSPROPTAG_Shuffle,
MSPROPTAG_RepeatSet,
MSPROPTAG_Recording,
MSPROPTAG_Rewind1,
MSPROPTAG_Rewind2,
MSPROPTAG_Rewind3,
MSPROPTAG_FF1,
MSPROPTAG_FF2,
MSPROPTAG_FF3,
MSPROPTAG_Next,
MSPROPTAG_Prev,
MSPROPTAG_Error,
MSPROPTAG_Ejecting,
// Media types
MSPROPTAG_MediaTypes = 0x2000,
MSPROPTAG_DVD,
MSPROPTAG_CD,
MSPROPTAG_PVR,
MSPROPTAG_StreamingContentAudio,
MSPROPTAG_StreamingContentVideo,
MSPROPTAG_TVTuner,
// Titles, numbers, strings, progress values and times
MSPROPTAG_MediaTime, // for the full CD or DVD
// These apply to tracks and chapters
MSPROPTAG_TrackNumber, // cd track, dvd chapter, tv channel
MSPROPTAG_TotalTracks,
MSPROPTAG_TrackDuration,
MSPROPTAG_TrackTime,
MSPROPTAG_TitleNumber,
MSPROPTAG_Volume, // in dB
MSPROPTAG_FS_Home,
MSPROPTAG_FS_TV,
MSPROPTAG_FS_DVD,
MSPROPTAG_FS_Guide,
MSPROPTAG_FS_Music,
MSPROPTAG_FS_Photos,
MSPROPTAG_FS_Videos,
MSPROPTAG_FS_RecordedShows,
MSPROPTAG_FS_Unknown,
MSPROPTAG_MediaName,
MSPROPTAG_ArtistName,
MSPROPTAG_TrackName,
MSPROPTAG_Photos,
MSPROPTAG_CurrentPicture,
MSPROPTAG_TransitionTime,
MSPROPTAG_GuideLoaded,
MSPROPTAG_SlowMotion1,
MSPROPTAG_SlowMotion2,
MSPROPTAG_SlowMotion3,
MSPROPTAG_NextFrame,
MSPROPTAG_PrevFrame,
MSPROPTAG_Radio,
MSPROPTAG_RadioFrequency,
MSPROPTAG_FS_Radio,
MSPROPTAG_Visualization, // an audio visualization is showing
MSPROPTAG_PhoneCall, // set when the phone is ringing
MSPROPTAG_CallingPartyNumber, // phone number of calling party
MSPROPTAG_CallingPartyName, // name of calling party
MSPROPTAG_ParentalAdvisoryRating, // a string such as "TV-G"
MSPROPTAG_RequestForTuner, // to broadcast that we need the tuner
// properties injected by the MSAS only - applications may not use these
MSPROPTAG_MSASPrivateTags = 0xf000,
MSPROPTAG_Application, // The name of the sourcing application
} MEDIASTATUSPROPERTYTAG;
typedef SAFEARRAY(MEDIASTATUSPROPERTYTAG) MEDIASTATUSTAGARRAY;
typedef SAFEARRAY(VARIANT) MEDIASTATUSPROPARRAY;
[
object,
uuid(A70D81F2-C9D2-4053-AF0E-CDEA39BDD1AD),
dual,
helpstring("IMediaStatusSession Interface"),
pointer_default(unique)
]
interface IMediaStatusSession : IDispatch
{
[id(1), helpstring("method MediaStatusChange")] HRESULT MediaStatusChange([in] MEDIASTATUSTAGARRAY Tags, [in] MEDIASTATUSPROPARRAY Properties);
[id(2), helpstring("method Close")] HRESULT Close();
};
[
object,
uuid(075FC453-F236-41DA-B90D-9FBB8BBDC1C5),
dual,
helpstring("IMediaStatusAggregator Interface"),
pointer_default(unique)
]
interface IMediaStatusAggregator : IDispatch
{
[id(1), helpstring("method CreateMediaStatusSession")] HRESULT CreateMediaStatusSession([in] BSTR ApplicationName, [in] BSTR WindowsSession, [out,retval] IMediaStatusSession** MediaStatusSession);
};
/*
* Media status sinks (the dll's that drive displays) must implement this interface. This interface is to be implemented on
* a co-class that is a member of the CATID_MediaStatusSink {fcb0c2a3-9747-4c95-9d02-820afedef13f} category.
* At startup, the media status aggregator will co-create all sink classes exposing this category id and will send updates to those
* sinks based on their windows session affinity.
*/
[
object,
uuid(075FC453-F236-41DA-B90D-9FBB8BBDC101),
dual,
helpstring("IMediaStatusSink Interface"),
pointer_default(unique)
]
interface IMediaStatusSink : IDispatch
{
[id(1)] HRESULT Initialize();
[id(2)] HRESULT CreateSession([out,retval] IMediaStatusSession** MediaStatusSession);
};
modified 16-May-21 21:01pm.
|
|
|
|
|
Grrrr... If you read the documentation on TlbImp, you will note that it works on Type Libraries (DLLs, TLBs) and NOT the Interface Definition Language (plain text files). Did a search MSDN and Goodle for these intrerface names and there is basically NO mention of these on the internet, because neither MSDN nor GOOGLE have come up with anything.... What IS this stuff?
|
|
|
|
|
My fault, i forgot about that and it was the first thing to come to my mind tLbimp the IDL. I look at the sdk and im creating a wrapper manually since the IDL didnt come with a Dll or tlb.
The code is for Microsoft Media Center. Its the Media State Aggregation Service, it lets user set up an PC case LCD display to show info about a current playing media, or an software to display info whatever i code it for.
I dont know much about C++, in class we never got this far, but can i just compile the IDL with a c++ compiler ( i need to find one)? if not i just continue creating a wrapper manually im almost done.
modified 16-May-21 21:01pm.
|
|
|
|
|
Hi Guys,
I just want to ask for suggestion regarding webcofig file. I declare my connection string in webconfig file so that all aspx can use the same connection under one project. (dynamic) rather than using the SqlConnection control from toolbox.
WEBCONFIG:
<add key="UserConnection" value="Data Source=localhost;server=os01;Initial Catalog=personnel ;User Id=person;password='per123'">
Question:
I'm using two server one for development and one for production. When I develop or maintain system I used of course the development which is named "os01".Is there anyway possible under webconfig file that when I transfer my project on our production machine which is named "os02" my webconfig file connection string will will detect that he is already using the production machine, from "os01"
it will become "os02" I don't have to change my webcofig file "CONNECTION STRING" everytime I change a server name.
I appreciate whatever ideas you will give, you will not only enlighten me but also others who will read this thread.
|
|
|
|
|
Is that so hard before you compile your setup project just click some keys and change 1 to 2?
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
Hi,
Actually it's only a blink of an eye. I'm just asking for suggestion to be more dynamic. I'm maintaining and dveloping multiple systems at the same time specially if there are urgent matters.
If you're not multi tasking then your answer is acceptable.
cheers
/dabsukol
|
|
|
|
|
Ok , one way which come to my mind is set two tag for it , when you are at debug time read it and when you use relaese setting for your project(which means its user machine) for your project read other tag. If its not clear just let me know and I explain more with details.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
If you plan on deploying this solution to machines using an installation project like a Windows Installer package (which VS.NET includes a basic Windows Installer project for doing just that), you could create your own Installer class that reads-in the Web.config file and changes the values in it based on the target machine, which it then saves back out to disk.
One more idea is to modify the Application_Start handler in the Global.asax file (or its code-behind file) that gets the machine name and conditionally updates the Web.config file, which will cause the web application to restart and your settings should be correct.
Otherwise, Mazdak's right. You'll just have to manage your project in a different manner using different build configurations or making the change after you move it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear friends,
Can I show the dialog with the effect like calling .ShowDialog(this)?
I want to call .Show() only, since .Show() won't cause the program wait in the instruction.
What I wnat to do is, I want to show one dialog in the top(locking UI a little time, like calling ShowDialog), then do the process in next instruction.
<br />
DialogDD wd = new DialogDD();<br />
wd.TopMost = true; <br />
wd.Show();
<br />
outThread = new Thread(new ThreadStart( this.ThreadProcess ));<br />
outThread.IsBackground = true;<br />
outThread.Start(); <br />
<br />
<br />
wd.Close();<br />
could someone give me some ideas? Thanks
|
|
|
|
|
This may not be the purest way to do what you ask, but it may accomplish what you want to do:
Add a timer to your DialogDD form.
In the Timer_Click event, do a Timer.Stop() and return.
On the other hand, if you are doing a progress bar kind of thing, then you may want to look at the DynamicSplashScreen project here on code project.
For example look here[^]
______________________________
The Tao gave birth to machine language. Machine language gave birth to the assembler.
The assembler gave birth to the compiler. Now there are ten thousand languages.
Each language has its purpose, however humble. Each language expresses the Yin and Yang of software. Each language has its place within the Tao.
But do not program in COBOL if you can avoid it.
|
|
|
|
|
I think what you're looking for is an owned window. Before calling Show , set the form's Owner property to whatever form should own the window (most likely the main application form). This results in that form always being on top of the owner form but allows the thread to continue. A good example of how this would look is a typical Find window, like in Internet Explorer or any of the Office programs that lets you keep the Find window on top of the other form but let you interact with the main application form. This also ensures that when the owner form is closed, the owned dialog is too.
Also, a form can own multiple forms, but a form can have only one owner.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
This results in that form always being on top of the owner form but allows the thread to continue.
yes, that's works, I have tried to set it's owner :
wd.Owner = this; // or this.MdiParent;
because this Form is an MDI child Form..
what I wnat to do is to make this dialog shows on the top of application, and hope it cannot be minimized until it has been closed.
if I only set its owner, it becomes able to minimize, how can I improve this ??
Thanks
|
|
|
|
|
If it's an MDI child, it can't really show on top of the MDI parent (at least, not using anything in the .NET FCL). Also, while you can disable the minimize and maximize boxes on the MDI child itself, if the MDI child is maximized, the minimize and maximize buttons are made available right below the MDI parent's like a common MDI application. There has been discussion on this before, but I believe without any resolution.
If you want the form to appear above the main application, then it shouldn't be an MDI child and should instead just be a regular form for which you set its Owner property.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I've been working on an MDI .NET project and am having a problem with my MDI children. There are 6 children that have no toolbars, some are resizeable. I want the user to be able to click anywhere on the child forms (except for controls) and drag that child around anywhere inside the MDI parent.
My problem is that I can't seem to get them to drag properly or look attractive while dragging. The mouse cursor will become offset during the drag and move ahead of the form, or there are bad trailing effects following the forms that won't go away until the user releases the mouse.
I've been unable to find any information that would help with effecient and attractive full-form dragging.
Basically I want to simulate dragging the form toolbar while clicking anywhere on the form. Any help or direction to an article/post would be very appreciated.
Cyric
|
|
|
|
|
I'm not sure how you're doing it now, but basically set a flag in the MouseDownm event handler (or better, override OnMouseDown , which also is better for the other events I'll mention - just don't forget to call base.OnEventName ). In the MouseMove handler move your form only if the flag is set. Finally, in the MouseUp handler reset the flag.
While moving the form, you have a couple of choices. You can simply set the Location property but that is what is most likely causing your lag (and related problems). There's quite a bit that happens in the implementation for setting the Location property. In the MouseDown handler, it might be better to call SuspendLayout and then call ResumeLayout in the MouseUp handler. I haven't tried this so I don't know how well this will work, and it may not even display the form while dragging.
You might instead consider P/Invoking the SetWindowPos API, which you can find more information about in the Platform SDK documentation in the MSDN Library[^]. This should result in much faster code and should eliminate that lag you're experiencing.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a collection that inherits the NameObjectCollectionBase and also has two internal state booleans. I need to serialize this collection and include the booleans. I implemented ISerializable but I cannot find very much step-by-step info. MSDN just shows using the GetObject() method to pass on to the base serializer which provides not help to me. The few articles here never touch on doing your own data serialization.
What I would like to do is serialize not only the objects in the collection, but also these two booleans. The SetType() seems to provide a means of defining the type to serialize. But everything else is Get methods to retrieve data from the SerializationInfo but I don't see how to integrate the booleans to the output. Do I just write out via the Context??? Do I set the info in the GetObject SerializationInfo object?
Any help in how to deploy this would be greatly appreciated.
|
|
|
|
|
You just need to call the base class's implementation after you serialize your own private members (or whatever else you want):
[Serializable]
public class MyNameObjectCollection : NameObjectCollectionBase
{
private int field1;
private string field2;
public MyNameObjectCollection() : base()
{
}
protected MyNameObjectCollection(SerializationInfo info,
StreamingContext context) : base(info, context)
{
field1 = info.GetInt32("field1");
field2 = info.GetString("field2");
}
public override void GetObjectData(SerializationInfo info,
StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("field1", field1);
info.AddValue("field2", field2);
}
}
<div style="width: 100%; font-size: 2px; margin-bottom: -10px; background-color: rgba(255, 153, 0, 1)"> </div>
Microsoft MVP, Visual C#
<a href="http://www.codeproject.com/script/articles/list_articles.asp?userid=46969">My Articles</a>
|
|
|
|
|
Hi everybody,
I'm asking for 2 things:
1-I want to know the equivelant Int value for some messages like WM_SETFOCUS , WM_ACTIVATEAPP ,..etc
From where can I get information about messages like that?
2-After catching a message sent to my application by overriding WndProc(),
Am I allowed to cancel or erase the effect of the received message? and how?
for Example: (When the user presses on Maximize button, I don'twant the window to be maximized).
thanks for Help
|
|
|
|
|
1. If you have Microsoft SDK look in the "include" directory for WinUser.h, it has ALL Windows messages defined there. If you don't have the SDK, either get it or Google for the message codes. If you have VB6 I think the API Viewer has the Windows messages as well.
2. You need to implement the IMessageFilter in some class and it's only method
bool PreFilterMessage(ref Message msg)
Check the message code in msg.Msg and return either 'true' if you want to cancel processing of this message and 'false' if you want to let it through to WndProc. If you want this filter application wide you can add this message filter like so:
MyMessageFilter mf = new MyMessageFilter();
Application.AddMessageFilter(mf);
If you want to process this on just one window, just override the WndProc method. And do not call the base.WndProc after you process a message.
|
|
|
|
|
I wonder if there is an equivalent of C# to the #define prepropcessor directive of C++. The one of C# is not very useful since you can not define macros. Can i use something else, which would perform the same functions. This will really clean my code.
|
|
|
|
|