|
Put your mouse over the type with the red line under it.
A small dropdown will appear below and to the left.
Open the dropdown, and it will offer a range of solutions for fixing the problem: the top one will probably be "using System.Text" for StringBuilder and "using System.Collections.Generic" for the Stack.
Click on that, and it'll add the required using line 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!
|
|
|
|
|
string s = "1234";
foreach ( char ch in s ) {
Console.WriteLine( $"{ch}: {( ch % 2 == 0 ? "even" : "odd" )}" );
}
Console.ReadKey();
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Thank you! ...I was looking for a complicate solution for a simple problem
|
|
|
|
|
You're welcome! The Char class has a lot of useful methods: .IsDigit(), .IsLetter(), etc.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Based on this document from apple : https://developer.apple.com/business/documentation/MDM-Protocol-Reference.pdf
Quote: I am trying to fetch mobile identifier by running provisioning profile on the device.
Here, I am able to get these identifiers: -
UDID
IMEI
ICCID
VERSION
PRODUCT
But this Identifier i.e. DeviceCapacity is not getting fetch.
Please find below is my code:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<dict>
<key>URL</key>
<string>https://xyz.com/home/checkin/?udi={0}</string>
<key>DeviceAttributes</key>
<array>
<string>UDID</string>
<string>IMEI</string>
<string>ICCID</string>
<string>VERSION</string>
<string>PRODUCT</string>
<string>SERIAL</string>
<string>MEID</string>
<string>DEVICECAPACITY</string>
</array>
</dict>
<key>PayloadOrganization</key>
<string>cellderetail-pro-new.cellde.com</string>
<key>PayloadDisplayName</key>
<string>Profile Service</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadUUID</key>
<string>9CF421B3-9853-4454-BC8A-982CBD3C907C</string>
<key>PayloadIdentifier</key>
<string>com.cellderetailpronewprovisioning</string>
<key>PayloadDescription</key>
<string>This temporary profile will be used to extract your current device's identifiers.</string>
<key>PayloadType</key>
<string>Profile Service</string>
</dict>
</plist>
Below is is the code for installing provisioning profile on ios device
var contentDisposition = new System.Net.Mime.ContentDisposition
{
FileName = "device-information.mobileconfig",
Inline = false
};
var path = Configuration.MobileConfigPath;
logger.LogMessage("MobileConfigPath" + path, FileLogger.MessageType.Info);
string mobileConfigPlist = System.IO.File.ReadAllText(path);
if (isHeadless)
udi = string.Format("{0}-hls-{1}-{2}-{3}-{4}-{5}-{6}", udi, storeId, StoreType, EnterpriseID,Session["TechName"],Session["Capacity"],Session["Model"]);
var plistWithUdiUrl = mobileConfigPlist.Replace("{0}", udi);
var bytes = getSignedContent(plistWithUdiUrl);
logger.LogMessage("Signed Content Bytes", FileLogger.MessageType.Info);
Response.AppendHeader("Content-Disposition", contentDisposition.ToString());
Response.AppendHeader("Cache-Control", "public, no-store, max-age=0");
return File(bytes, "application/x-apple-aspen-config");
As kind of help / suggestion are welcomed
|
|
|
|
|
The fields you're querying require different access rights, including "Device Information" access rights.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi, friends. I want to create e User Control that contains two components: a textbox and a combobox. Both must be connected to a database (SqlServer, for instance). I know how to connect the combobox, also inside the UC, but in an instance of the UC I don’t. What I want is to add this new component to a form application and to make the connection, but different tables at a time. Can anybody help me?
Thanks.
|
|
|
|
|
You'll need to either provide a Constructor or a Property that allows you to pass the table name into the UserControl when it is created, and provide methods to connect and disconnect the instance - almost certainly, a property is a better idea as you can't call a parameterized constructor from the VS designer (even creating a parameterized constructor will break the designer!)
"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!
|
|
|
|
|
You can have parameterized constructors if you also have a default constructor for the designer. I use parameterized constructors when I add UC's on the fly, and sometimes add a private default constructor so it can only be used on the fly.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
They must have fixed a bug - the designer used to puke it's guts up if you dropped a UC on a form and it had an overloaded constructor. Been a while since I tried as a reason!
"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!
|
|
|
|
|
I would like to show a WinForms MessageBox centered on top of another application's (TortoiseGit) "sub"-form, i.e. a form (the TortoiseGit checkout form) on top of the main form (the TortoiseGit log window). I am able to successfully find the process (TortoiseGitProc) and from there I can successfully get a MainWindowHandle to the main form, but how do get from there to the "sub"-form (the TortoiseGit checkout form)?
|
|
|
|
|
|
When I use the code from PINVOKE: Getting all child handles of window · Software adventures and thoughts[^] to get all the children, I get 30 pointers. When I then log the Window texts using the following
List<IntPtr> allChildWindows = new WindowHandleInfo(parentMainWindowHandle).GetAllChildHandles();
for (int i = 0; i < allChildWindows.Count; i++)
{
StringBuilder sb2 = new StringBuilder(1024);
GetClassName(allChildWindows[i], sb2, sb2.Capacity);
sb2 = new StringBuilder(1024);
GetWindowText(allChildWindows[i], sb2, sb2.Capacity);
Debug.WriteLine(sb2.ToString());
}
then I get mostly empty strings, but I do get some strings that appears to come from the main form's (not the "sub"-form's) components (buttons, labels, etc), e.g. "<all branches="">", "Help", "Refresh", "Walk Be&haviour", "&View", "OK", etc. What am I doing wrong, why do I get pointers to the main form's components and not to the "sub"-form?
|
|
|
|
|
|
I made a dump of all windows using Spy++ and this what I got:
Window 000C0678 "C:\DummyRepo - Switch/Checkout - TortoiseGit" #32770 (Dialog)
Window 000B0670 "" ScrollBar
Window 00070482 "Switch To" Button
Window 001D065E "&Branch" Button
Window 000B01AE "" ComboBoxEx32
Window 0004036E "ⴀ辘ȡ" ComboBox
Window 0017069A "..." Button
Window 001303D2 "&Tag" Button
Window 000B04DE "" ComboBoxEx32
Window 001105D4 "" ComboBox
Window 00190620 "&Commit" Button
Window 000F06D8 "c288b35fcabf74c51270fff36db3387517beda53" ComboBoxEx32
Window 001406CE "Ɒ辘ȡ" ComboBox
Window 001005CE "c288b35fcabf74c51270fff36db3387517beda53" Edit
Window 00220458 "..." Button
Window 00170604 "Option" Button
Window 000E0684 "Create &New Branch" Button
Window 002503EA "Branch_c288b35f" Edit
Window 00390628 "Overwrite working tree changes (&force)" Button
Window 004404EE "&Merge" Button
Window 00300666 "T&rack" Button
Window 0040045C "&Override branch if exists" Button
Window 001404DC "OK" Button
Window 0008025E "Cancel" Button
Window 00220396 "Help" Button
Window 00040616 "C:\DummyRepo - Log Messages - TortoiseGit" #32770 (Dialog)
Window 000D04E6 "" Static
Window 002A0602 "" Static
Window 00040622 "master" Static
Window 002204CA "From:" Static
Window 001104C2 "2020-07-31" SysDateTimePick32
Window 001904A4 "To:" Static
Window 001A0496 "2020-07-31" SysDateTimePick32
Window 000F0560 "" Edit
Window 00080638 "Author Email" ComboBox
Window 000F01F2 "" Button
Window 001904B0 "" Button
Window 00190498 "" SysListView32
Window 00150422 "" SysHeader32
Window 00350426 "SHA-1: c288b35fcabf74c51270fff36db3387517beda53
* 1
" RICHEDIT50W
Window 005B04E4 "" Static
Window 001104F0 "" SysListView32
Window 0013045E "" SysHeader32
Window 004A06CA "Showing 2 revision(s), from revision c288b35f to revision b7a040a4 - 1 revision(s) selected, 0 file(s) selected; line: 1(+) 0(-) files: modified = 0 added = 1 deleted = 0 replaced = 0" Edit
Window 0017060A "Show &Whole Project" Button
Window 001705FC "&All Branches" Button
Window 00290424 "" Edit
Window 00460660 "Help" Button
Window 0019048C "Refresh" Button
Window 004A065C "S&tatistics" Button
Window 000D036A "Walk Be&haviour" Button
Window 00160492 "&View" Button
Window 0016048E "OK" Button
Window 004B069E "OK" Button
Window 0024064A "" msctls_progress32
Window 0004061A "" ScrollBar So, it seems the Switch/Checkout window is not a child or a "sub" form of the Log Message window, they certainly seem to be on the same level (both are "sibling parents"?). So, I guess I'm back to square one. Does anybody know how I can find the Switch/Checkout window instead of the Log Message window? When I obtain a MainWindowHandle from the process name (TortoiseGitProc) it returns a pointer to the Log Message window. Does anybody know what I should do?
|
|
|
|
|
Keep doing what you're doing; that's what it's all about. The documented and the undocumented. Maybe it's using a cloaking device. Sounds like a security hole otherwise. ("Masking")
automation - Enumerating Windows/Controls of another application from .Net - Stack Overflow
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
modified 31-Jul-20 18:51pm.
|
|
|
|
|
Isn't this the window you want?
arnold_w wrote: Window 000C0678 "C:\DummyRepo - Switch/Checkout - TortoiseGit" #32770 (Dialog)
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Yes, absolutely. But I don't want to have to use Spy++ to find it, I want to be able to find it in my C# application, but the C# application appears to find this window instead:
Window 00040616 "C:\DummyRepo - Log Messages - TortoiseGit" #32770 (Dialog) It would be ok if I can find both, but then I would need to somehow obtain the heading strings ("C:\DummyRepo - Log Messages - TortoiseGit" and "C:\DummyRepo - Switch/Checkout - TortoiseGit") so that I have a way to distinguish which window (or actually, dialog) is which.
|
|
|
|
|
Instead of using Process.MainWindowHandle (which only returns the "C:\DummyRepo - Log Messages - TortoiseGit" window) I guess I could iterate through all windows using the technique described in Winforms-How can I make MessageBox appear centered on MainForm? - Stack Overflow[^]. However, when I do so and log the window texts, I never find the strings "C:\DummyRepo - Log Messages - TortoiseGit" and "C:\DummyRepo - Switch/Checkout - TortoiseGit":
[DllImport("user32.dll", EntryPoint = "GetWindowText",
ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount);
private bool checkWindow(IntPtr hWnd, IntPtr lp)
{
StringBuilder sb = new StringBuilder(260);
GetClassName(hWnd, sb, sb.Capacity);
StringBuilder strbTitle = new StringBuilder(255);
int nLength = GetWindowText(hWnd, strbTitle, strbTitle.Capacity + 1);
string strTitle = strbTitle.ToString();
Debug.WriteLine("The window text is: " + strTitle);
if (sb.ToString() != "#32770")
{
return true;
}
return true; The strings I find appear to be much more low-level, e.g "Form1", "MSCTFIME UI", "Default IME", etc. Does anybody know which function I should use instead to obtain the window headings, "C:\DummyRepo - Log Messages - TortoiseGit" and "C:\DummyRepo - Switch/Checkout - TortoiseGit"?
|
|
|
|
|
This is kind of a side point, but I see that your CheckWindow function will return true in any circumstance.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Yes, I added the line
return true; on purpose because I wanted to log all window texts. My goals was to find the particular window that has the window text "C:\DummyRepo - Switch/Checkout - TortoiseGit", but all I found was windows having window texts such as "Form1", "MSCTFIME UI" and "Default IME".
|
|
|
|
|
|
That's pretty much what I already do, I am able to get a bunch of windows but I can't tell which one corresponds to
Window 000C0678 "C:\DummyRepo - Switch/Checkout - TortoiseGit" #32770 (Dialog) because I can't find any window that has the heading "C:\DummyRepo - Switch/Checkout - TortoiseGit" using GetWindowText.
Now, on the other hand, the pure C# (no win32 pinvoke involved) property Process.MainWindowTitle seems to return the proper string, but I can only apply it to the de facto main window ("C:\DummyRepo - Log Messages - TortoiseGit"), not to the "secondary sibling"-window ("C:\DummyRepo - Switch/Checkout - TortoiseGit").
|
|
|
|
|
That's not what you're already doing. You must be looking at the first answer to the question.
Look at the SECOND answer to the question on that page.
The second answer uses the function EnumThreadWindows.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Ahhh, you mean this:
const uint WM_GETTEXT = 0x000D;
StringBuilder message = new StringBuilder(1000);
SendMessage(handle, WM_GETTEXT, message.Capacity, message); Yes, that works great!!! Thank you! This is the complete code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
WindowWrapper parentForm = ProcessWindowsHelper.getHandleToAnotherProcessWindow("TortoiseGitProc", "Switch/Checkout");
MessageBoxEx.Show(parentForm, "Hello on top of TortoiseGit Switch/Checkout dialog");
}
}
public class ProcessWindowsHelper
{
private delegate bool EnumThreadWndProc(IntPtr hWnd, IntPtr lp);
[DllImport("user32.dll")]
private static extern bool EnumThreadWindows(int tid, EnumThreadWndProc callback, IntPtr lp);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam);
delegate bool EnumThreadDelegate(IntPtr hWnd, IntPtr lParam);
private const uint WM_GETTEXT = 0x000D;
public static WindowWrapper getHandleToAnotherProcessWindow(string processName, string substringInAnotherProcessWindow)
{
Process myProcess = findProcessByName(processName);
IEnumerable<IntPtr> allHandlesInMyProcess = EnumerateProcessWindowHandles(myProcess.Id);
foreach (IntPtr handle in allHandlesInMyProcess)
{
StringBuilder message = new StringBuilder(1000);
SendMessage(handle, WM_GETTEXT, message.Capacity, message);
if (message.ToString().Contains(substringInAnotherProcessWindow))
{
Debug.WriteLine(message);
return new WindowWrapper(handle);
}
}
return null;
}
private static IEnumerable<IntPtr> EnumerateProcessWindowHandles(int processId)
{
List<IntPtr> handles = new List<IntPtr>();
ProcessThreadCollection processThreadCollection = Process.GetProcessById(processId).Threads;
for (int i = 0; i < processThreadCollection.Count; i++)
{
ProcessThread thread;
thread = processThreadCollection[i];
EnumThreadWindows(thread.Id,
delegate(IntPtr hWnd, IntPtr lParam)
{
handles.Add(hWnd);
return true;
},
IntPtr.Zero);
}
return handles;
}
private static Process findProcessByName(string processName)
{
Process[] allProcesses = Process.GetProcesses();
for (int j = 0; j < allProcesses.Length; j++)
{
if (allProcesses[j].ProcessName.Equals(processName))
{
return allProcesses[j];
}
}
return null;
}
}
public class WindowWrapper : IWin32Window
{
public WindowWrapper(IntPtr handle)
{
_hwnd = handle;
}
public IntPtr Handle
{
get { return _hwnd; }
}
private IntPtr _hwnd;
} The class MessageBoxEx can be found here: Parent centered MessageBox dialog in C# · GitHub[^]
modified 1-Aug-20 9:49am.
|
|
|
|
|