|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
hi all,
is there any option to get image file thumbnail ,but without open the image file.
please guide me for this.
thanks in advance.
|
|
|
|
|
Maybe hire a medium to generate their interpretation of the contents of a file they've never seen?
Seriously, how do you think it would be possible to generate a smaller version of the image in a file without opening that file to see what the image is?
This sounds like an XY problem[^]. Perhaps if you ask for help with the issue you're actually trying to solve, rather than asking for help implementing the solution you think you need, then you might have better luck.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
To back up what Richard says, what you are asking for is logically impossible: it's like saying "write me a summary of this book, but don't read it first". You can't write an accurate summary without knowing what happens in the story!
The same applies to images: you can't create a thumbnail without access to the original image.
So as Richard suggests: think about the problem you are trying to solve instead of the solution you have conceived - there may be a better way to complete your task. Or even a possible one!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
FileStream fs = new System.IO.FileStream(img_path, FileMode.Open, FileAccess.Read);
img = Image.FromStream(fs);
Image imgThumb = img.GetThumbnailImage(thumbnailSize.Width, thumbnailSize.Height, null, IntPtr.Zero);
fs.Close();
fs.Dispose();
img.Dispose();
i use this for getting thumbnail, but it takes time if file is large,or i take tumbnail of multiple big size images....
that's why i ask its possible to get image thumbnail without using the image file.
is this possible with the use of "IExtractImage"
|
|
|
|
|
You're going to have the performance problem no matter what. Even using whatever interface that is, it's going to have to open the file and read the entire thing to generate the thumbnail.
|
|
|
|
|
i am create a PDF file using Microsoft Print to PDF,
PaperSize paperSize = new PaperSize("Custom", 400, 200);
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = "Microsoft Print to PDF";
pd.PrinterSettings.PrintToFile = true;
pd.PrinterSettings.PrintFileName = PDF_File_name;
pd.DefaultPageSettings = Default_PrintProfile_PDF;
pd.PrinterSettings.DefaultPageSettings.PaperSize = paperSize;
pd.DefaultPageSettings.PaperSize = paperSize;
pd.PrintController = new StandardPrintController();
pd.PrintPage += PrintPage_As_PDF;
pd.Print();
but custom size not set, printable area is eqal to letter paper size.
please help me for this.
|
|
|
|
|
Yousef10 @ stackoverflow (SOS: "Microsoft Print PDF" PaperSize) says "don't worry" ... it's the printer's fault. And your code's the same as his; so first step -> try running your print PDF routine with a different printer?
|
|
|
|
|
Is there a way to set where to drop an event handler? When I double click on a button it drops mine at line 1500 for some reason. Then I have to cut and paste. It's doing it in a region of code and it expands that region, which is a little annoying. I'm hoping to drop at the top somewhere, possible?
|
|
|
|
|
Annoying, isn't it?
I've never found a solution to that either, and I've been using VS for 15 years ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
YES VERY VERY ANNOYING lol!! Kind of glad I'm not alone! Come on MicroSoft. Geez a whiz. It puts it in a random spot in the middle of nowhere. Where's the add event by line number?? That would make so much sense. Why MicroSoft Whyyyyy??? It would also be nice to apply a static do not expand my code unless I absolutely say so clause. And my last rant of the day is the 3 word line of code that can be simplified warning? Ok it's 3 words how much simpler can it be? I have a few more rants, but I'll table them for another day. Other than that it's a great product. And if I knew someone that was professional at this to tell me where and why's of doing things I would probably rant a lot less. But as it is all I have is Youtube and a lot of books. And nice forums like this one. So let's all be friends and give us our event handler by line number !
|
|
|
|
|
geomeo123 wrote: Where's the add event by line number?
Well ... no. Line number isn't helpful, and it's far too easy to add it in the wrong place and get code that doesn't compile - which might be quite difficult to spot! I'd rather have to move it to the right region of the file manually - which isn't hard to do - than have it appear in the middle of an XML comment, or a switch block for example.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Quote: and it's far too easy to add it in the wrong place and get code that doesn't compile
That would be pretty impossible. Since any time you click for the eventHandler MicroSoft prompts you exactly where your event code has landed so that you can start writing what you want to do when the event has occurred. I'm fairly sure choosing the line number rather than have that done for us would work.
|
|
|
|
|
You can manually add the handler name to your button in the properties window, and then add the actual handler code wherever you want.
|
|
|
|
|
Can you explain? You lost me on the word manually? Do you mean manually type it in to the event handler property text box then manually write it to whereever I want? Screenshots would be nice.
|
|
|
|
|
It seems that things have changed since I last did this, and even typing the event name into the event handler, VS automatically adds the handler skeleton at the end of the Form class.
|
|
|
|
|
Find a program with over 1500 lines of code. It doesn't add to the end of the code anymore. (which would be nice too).
|
|
|
|
|
Where would VS know where to definitively add the handler, other than at the end of the class definition in the first file of the class?
The code for a Form class could be spread across several files, so this makes identifying a target location harder. I organize my code in #region elements and have gotten (there - I said it ) used to moving the handler to an appropriate location.
/ravi
|
|
|
|
|
I have an application developed in Visual Studio 2022 that works with forms. In this application, there is a main form, from which other forms can be opened. In this main form, there is an item in the top menu (“selection”), whose name is M_Selecao, which must be activated or deactivated depending on which form was opened.
For example, when the “Expenses” form is opened, the menu must be activated (enabled).
When this secondary form is closed, the “selection” menu must be disabled. I can enable the menu, but I can’t disable it. I tried to make the main form’s menu “public” in the “TelaPrincipal.Designer.cs” file:
public System.Windows.Forms.ToolStripMenuItem M_Selecao;
This way I could disable the menu in the main form when closing the secondary form, but I get the message that "an object reference is required for the method or property 'TelaPrincipal.M_Selecao'. I also don't know how to do it from the main form. Can anyone help me? Thanks.
|
|
|
|
|
|
Ok, Richard. I'll try it. Thanks
|
|
|
|
|
OK, let's take this in two stages, starting with your error message:
An object reference is required for the non-static field, method, or property 'TelaPrincipal.M_Selecao' This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself.
Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null - which means that there is no instance of a class in the variable.
It's a bit like a pocket: you have a pocket in your shirt, which you use to hold a pen. If you reach into the pocket and find there isn't a pen there, you can't sign your name on a piece of paper - and you will get very funny looks if you try! The empty pocket is giving you a null value (no pen here!) so you can't do anything that you would normally do once you retrieved your pen. Why is it empty? That's the question - it may be that you forgot to pick up your pen when you left the house this morning, or possibly you left the pen in the pocket of yesterday's shirt when you took it off last night.
We can't tell, because we weren't there, and even more importantly, we can't even see your shirt, much less what is in the pocket!
Back to computers, and you have done the same thing, somehow - and we can't see your code, much less run it and find out what contains null when it shouldn't.
But you can - and Visual Studio will help you here. Run your program in the debugger and when it fails, it will show you the line it found the problem on. You can then start looking at the various parts of it to see what value is null and start looking back through your code to find out why. So put a breakpoint at the beginning of the method containing the error line, and run your program from the start again. This time, the debugger will stop before the error, and let you examine what is going on by stepping through the code looking at your values.
But we can't do that - we don't have your code, we don't know how to use it if we did have it, we don't have your data. So try it - and see how much information you can find out!
The second part is what you are trying to do, and the whole way you are going about it - so let me summarise what you are trying to achieve:
You have a main form which opens a "child" form. When some of these forms are opened, a main form menu option must be enabled, and disabled again when it closes.
First off, don't make the menu item public so that the child forms can enable or disable it - that requires the child form to "know" about how it's parent works and even that a specific parent type exists - which is against the principles of OOPs design, and complicates your code.
Secondly, that's a pretty nasty things to do, because in order to activate the menu item, the child form cannot be modal - which means it must be opened by calling Show instead of ShowDialog . The difference is that a modal form (opened with ShowDialog ) does not allow the user to continue working with the main form until the child form is closed so that menu options can't even be selected. Opening it with Show does allow the user to continue working with the main form and thus selecting items from the menu, but ... it also allows the user to do whatever opened the child form in the first place!
Which means he can open a second copy of the child form, or worse of a form that should have the menu option disabled. What state should the menu option be in then? Enabled (because the original child is open) or disabled (because a different child is also opened)? From the perspective of the user that's confusing, and could lead to problems!
So first you need to think about what you are trying to do: open a form and enable the menu item - but forbid any other form from opening, or enable and disable the parent form menu item not just when the child form is open, but when it has the input focus as well! Both can be done, but they require changes in the parent form, and communications between the two forms - the child form must tell the parent what is happening and let it decide what to do instead of trying to make changes to it itself. The way that is done in C# is via events just like clicking a button raises an event your form handles. Those aren't actually difficult to work with - though they can seem confusing - all you have to do is know how to create and raise them.
When you have decided exactly what you want to happen have a look here: Transferring information between two forms, Part 2: Child to Parent[^] - it explains how to do talk from your child form to the main form and provides sample code. You can create events to ask the parent form to Enable or Disable the menu item and let it worry about everything else - the child form then raises the event as needed and the main form just handles it internally.
I know that all probably sounds confusing and you probably wanted us to just give you code which solved your problem but it's not that simple - you need to make decisions about how your app is supposed to work, and we can't do that for you!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Once again you help me, OriginalGriff. I'll Think about. Thanks.
|
|
|
|
|
Good afternoon,
a bit stumped with this one - any help would be greatly appreciated:
System.Void, System.Object, System.Inptr not defined or imported... a little bit stumped with this one... any help would be greatly be appreciated...
Regards,
Pieter Claassens
|
|
|
|
|