|
Thanks. I think I may have tried that. But it's possible I'm wrong, so I'll doublecheck.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I can't describe the problem very clearly
I want to do taskbar thumbnails with windows API code packs that can be displayed normally but move to main window already loaded state; i do not know how to fix
I'm just implementing the thumbnail image, but this move to the thumbnail window becomes the loading state
using Microsoft.WindowsAPICodePack.Taskbar;
private TabbedThumbnail customThumbnail;
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
customThumbnail = new TabbedThumbnail(this.Handle, this.Handle);
TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(customThumbnail);
customThumbnail.TabbedThumbnailBitmapRequested += customThumbnail_TabbedThumbnailBitmapRequested;
}
private Bitmap GenerateBitmap()
{
Bitmap bitmap = new Bitmap(150, 150);
using (var g = Graphics.FromImage(bitmap))
{
g.DrawImage(Properties.Resources.tx, new Rectangle(0,0,150,150));
}
return bitmap;
}
void customThumbnail_TabbedThumbnailBitmapRequested(object sender, TabbedThumbnailBitmapRequestedEventArgs e)
{
var bitmap = GenerateBitmap();
customThumbnail.SetImage(bitmap);
ThreadPool.QueueUserWorkItem(c =>
{
Thread.Sleep(2000);
this.Invoke(new MethodInvoker(InvalidateThumbnail));
});
}
private void InvalidateThumbnail()
{
customThumbnail.InvalidatePreview();
}
modified 29-May-17 10:35am.
|
|
|
|
|
|
Your question made no sense at all.
|
|
|
|
|
Hi all,
i have declared a string below which will be a switch to a command.
string prnportpatha=@"\\servername\apps\Utilities\AddPrinter\prnport.vbs";
how do i call the variable in a command as per below
proc.StartInfo.FileName=("cmd.exe");
proc.StartInfo.Arguments=("/k cscript " + prnportpatha);
this doesnt seem to work, i get the error:
the name prnportpatha does not exist inthe current context.
|
|
|
|
|
When you get an error message like:
the name prnportpatha does not exist inthe current context. What the compiler is saying is "I looked for something called 'prnportpatha' everywhere that I can, but I can't find it".
Normally there are two reasons for this:
1) You spelled it wrong. Check: C# is case sensitive, so "prnportpatha" is not the same as "prnPortPatha".
2) It's not in scope. This is complicated, but if you declare a variable, you can't use it outside the same set of curly brackets:
if (myCondition)
{
string s = "hello";
Console.WriteLine(s);
}
Console.WriteLine(s);
This applies to all declarations: fields, properties, methods, events, delegates, ... everything. Once it goes out of scope, you can't access it directly. There are ways to access public (and protected, and internal) items via the class name (for static items, or via an instance (for non-static items) but generally speaking, unless it is in the same scope (or set of curly brackets, basically) you can't access it.
If you can't work it out from that, you need to post the relevant code fragments and we will look at them.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
here is the code fragment.
static void Main()
{
string prnportpatha=@"\\servername\apps\Utilities\AddPrinter\prnport.vbs";
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName=("cmd.exe");
proc.StartInfo.Arguments=("/k cscript prnportpatha, " -a -r IP_"+ip+" -h "+ip+" -o raw -n 9100");
proc.Start();
MessageBox.Show("Printer Installed");
}
|
|
|
|
|
In your sample-code the string belongs (only) to the Main-method.
As OG has told you (in his sample-code) : the string is outside the Main-method not existant for other methods.
So you should declare it outside the Main-method and see what happens ...
|
|
|
|
|
And the definition is inside the curly brackets for the main method: which means it's scope is that method, and that method only - it isn't available outside at all.
You could try declaring it outside the method:
private string prnportpatha=@"\\auoa1ws1001\apps\Utilities\AddPrinter\prnport.vbs";
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
.... But it's a bad idea to "hard-code" strings anyway - the actual string you set it to should be in a configuration file that is loaded in your main method so you don't have to recompile your application when it changes (and it will, it will...)
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You have two problems here:
1. Your string is declared in method Main , so it is not visible in method button1_Click .
2. You have included the name prnportpatha inside quotes in your setting of proc.StartInfo.Arguments .
You need to move the string declaration outside of Main so it is visible to all methods of your Form class. Also you need to fix your parameters so it creates the correctly formatted argument string.
|
|
|
|
|
I know how to say:
public class MyClass<T>
{
}
But is it possible to specify that T must have a certain base class? What is the syntax for that?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Thanks so much, Griff.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
No problem!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Message Closed
modified 28-May-17 16:30pm.
|
|
|
|
|
You return a different list to the one you are adding records into.
This space for rent
|
|
|
|
|
The question is simple, I have a code that's using the PostMessage function like so :
public enum WMessages : int
{
WM_MOUSEMOVE= 0x0200,
WM_LBUTTONDOWN = 0x201,
WM_LBUTTONUP = 0x202,
WM_RBUTTONDOWN = 0x0204,
WM_RBUTTONUP = 0x0205,
WM_KEYDOWN = 0x100,
WM_KEYUP = 0x101,
WH_KEYBOARD_LL = 13,
WH_MOUSE_LL = 14,
}
[DllImport("User32.Dll", EntryPoint = "PostMessageA")]
static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
private int MAKELPARAM(int p, int p_2)
{
return (p_2 * 0x10000 + p);
}
public void SendClick(WMessages type, Point pos, IntPtr hwnd)
{
switch (type)
{
case WMessages.WM_LBUTTONDOWN:
PostMessage(hwnd,
(int)0x201, 1,
MAKELPARAM(pos.X, pos.Y));
return;
case WMessages.WM_LBUTTONUP:
PostMessage(hwnd,
(int)WMessages.WM_LBUTTONUP, 0,
MAKELPARAM(pos.X, pos.Y));
return;
default:
return;
}
}
The only problem is that it clicks in a wrong place. For example, if i input the point 50,50 it'll click in 70,70 for example, offsetted to the window handle.
I wonder why it happens? Hope to get an answer.
Thanks in advance.
Example :
IntPtr atat = (IntPtr)0x00010870;
SendRClick(WMessages.WM_RBUTTONDOWN, new Point(50, 50), atat);
SendRClick(WMessages.WM_RBUTTONUP, new Point(50, 50), atat);
Edit :
I've found something interesting, apparently it happens only in 1 of my screens (I have 2), in the other one its not happening.
The screen that it happens in's resolution is 1920/1080, the screen that does it correctly's resolution is 1280/1024 (my main screen, does it correctly).
Edit 2 :
Also another thing that I've forgot to mention, the ratio between the resulted point to the inserted point is 1.5 in X and also in Y.
For example, if I've entered X=100,Y=100, it'll be resulted in 150 X and 150 Y offset from the window handle.
Edit 3 :
An alternative would be to devide the x and y by 1.5 and then it'll be multiplied again by default... but its not really an answer
|
|
|
|
|
1920 is 1.5 x 1280 ....
Appears you may not be handling individual screens / properties properly...
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
|
Hello,
I'm looking to make a web service to be available in the form
of ASP.NET MVC routing, meaning "base_url/controller/action",
optionally with some extra parameters for GET requests, plus
some other "actions" for POST requests.
I would like to first test them locally, on "localhost",
then if everything's OK to deploy them onto a remote
server and then test remotely, in the interest of
eventually publishing that web service to my customers.
Using "VS Express 2012 for Web", and also the equivalent
edition "VS Express 2012 for Desktop", I've been able
to make an "ASP.NET MVC 4 Web Application" with
a "Web API" template, and also a client console application
to send POST requests with, for QA purposes.
The "Web Service" project has been partially created in accordance
with a Youtube video of "REST API in ASP.NET MVC", by Michael Crosby,
available at "http://www.youtube.com/watch?v=agImzri6X64", where
he presents a pretty good way on how to do both consuming AND returning
of JSON, however at some points he refers the viewers to some external library
which unfortunately didn't compile.
The "Web Service" project itself seemed to have tested OK locally,
both for GET and POST requests, however when tested remotely
on a cloud-based server, the POST request returned a 404 error.
The "POST request maker" console application has been borrowed "as is"
from MSDN, at "msdn.microsoft.com/en-us/library/debx8sh9(v=vs.110).aspx",
and seemed to have tested OK on both "localhost" for GET and POST requests
but NOT so well remotely.
My questions are :
1) What would be the absolutely minimum set of steps required to make
a C# web service allowing both GET and POST of JSON strings ?
2) What files would I have to deploy on a remote server (IIS 10 I think)
preferably without the ".cs" source files, in order to make
that web service available online ?
- What I've previously attempted was a simple ZIP and UnZip of all
of the project files into "C:\inetpub\wwwroot", and it did return
the "View" for the template's homepage correctly.
3) Are there any extra configurations to be made on either
the web service project's files or the server's IIS panel ?
Any advice would be greatly appreciated
Thanks in advance
Me, a puzzled developer...
|
|
|
|
|
Hello everyone,
I am creating a G & M code interpreter for CNC machines using Microsoft visual C#. It requires displaying a 3D model of a CNC machine, which I have deigned in 3D Studio Max 2017. Now, I want to import it in my Winform using a 3D engine. The one that I have been trying on is TrueVision3D SDK. But I am unable to show any output on my Winform. I always get error as some file is missing or etc... SO can you guys suggest me some other 3D engine so that I could accomplish my task? Or how I could do the same with TrueVision3D?
|
|
|
|
|
|
You can embed a WPF control on your winform.
How to Easily Host WPF Control inside Windows Form Application[^]
The WPF control can then display the 3D model.
WPF 3D: Part 1 of n[^]
I do not know if these articles are the best around, they are just what I found first. I have successfully done this many years ago and I do not recall any major problems with this approach.
You might need to find a library or manually code something to get the mesh into WPF from your file format - personally I did it manually as I had a non-standard format to start with (A flight simulator 3D file) and already had code to load the mesh as I was doing manipulations on it.
|
|
|
|
|
Thank you for your help. Actually the issue I am facing with TrueVision 3D is that the I have to Make the "Embed Interop" option in C# as false. Otherwise the C# gives error. Maybe because of that, I am not getting any output.
|
|
|
|
|
Anyone can help me to retrieve image from multiple folders from SharePoint? I'm using C# windows form. Thanks. Here is my current code & not work to retrieve from SharePoint.
private void textBoxEmpno_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
if (textBoxEmpno.Text != "")
{
bool isDataFound = false;
try
{
string baseFolder = "URL SharePoint";
string[] employeeFolders = Directory.GetDirectories(baseFolder);
string imgName = textBoxEmpno.Text + ".jpg";
bool fileFound = false;
foreach (var folderName in employeeFolders)
{
var path = Path.Combine(folderName, imgName);
if (File.Exists(path))
{
pictureBox1.Visible = true;
pictureBox1.Image = Image.FromFile(path);
fileFound = true;
}
}
if (!fileFound)
{
pictureBox1.Visible = true;
pictureBox1.Image = Image.FromFile(@"C:\Users\hamizah\Desktop\images\photo\No-image-found.jpg");
}
pictureBox1.Visible = false;
}
finally
|
|
|
|
|