[Solved] How to use multiple fonts for each combobox item in WPF?

You can implement this easily by using data binding with item template inside comboBox as following: First of all you need to create item template for your ComboBox, which can be done in many ways, Iam going to use the simplest way as following: <ComboBox Width=”200″ Height=”35″ VerticalContentAlignment=”Center” ItemsSource=”{Binding Items}”> <ComboBox.ItemTemplate> <DataTemplate DataType=”{x:Type local:ItemViewModel}”> <StackPanel … Read more

[Solved] Differentiating between password and other kind of keyboard inputs in a keylogger

If the foreground app is using standard Win32 UI controls, then try this: use GetForegroundWindow() to get the HWND of the foreground window. then use GetWindowThreadProcessId() and GetGUIThreadInfo() to get the foreground window’s currently focused child control. then use GetClassName() to check if it is a standard EDIT control (this check might fail in some … Read more

[Solved] How to check if an array contains a value stored in a variable

If you want to see if a value is in the array, use Contains function. If you want to check whether arrays are equal use StructuralComparisons.StructuralEqualityComparer. (https://docs.microsoft.com/en-us/dotnet/api/system.collections.structuralcomparisons.structuralequalitycomparer?view=netframework-4.7.2) Code static void Main(string[] args) { int compValue = 5; int[] values0 = { 1, 2, 5, 7, 8 }; void ContainsValue(int[] array, int valueToTest) { bool isContained … Read more

[Solved] Declare variables inside loops the right way?

As mentioned by πάντα ῥεῖ in the comments, you can’t create new variable names dynamically at runtime in C++. All variable names must be known at compile-time. What you need to do here is use array indices instead. For example, change somedata and Do to std::vectors. Something like this: std::vector<bool> Do(5); // contains 5 bools, … Read more

[Solved] how to write a function for numbers

You’re already given the function signature: int largest(), so that’s exactly how you’d write the function (exactly like int main();): // Declares the function int largest(); // Defines the function: int largest() { // The function MUST return an int (or something convertible) otherwise it will not compile return 0; } Or you can combine … Read more

[Solved] Upcast, downcasting, and hiding methods in C++ [closed]

About question #1: yes, if you provide a factory method along with your ‘simple’ interface: class B { public: static B * create(); virtual void simple() = 0; }; in B’s implementation file (cpp): B *B::create() { return new D(); //or whatever ‘hidden’ implementation } About your #2: hiding functionality means simplification in the first … Read more

[Solved] can you iterate over a vector within a while statement?

you can write a function to do this (here I use a lambda, you can also use normal function) auto condition=[&]{ for(auto& r:r_use) for(int i=0;i<R;++i) if(r[i]<=r_max[i]) return false; return true; }; while(condition())run_function(r_use); or you can (better not) use algorithm library like this (just implement your first snip) while(std::all_of(r_use.begin(),r_use.end(),[&r_max](auto& rs){ return std::all_of(rs.begin(),rs.end(),[&,start=rs.data()](auto& d){ return d>r_max[&d-start];});}) )run_function(r_use); … Read more

[Solved] How to write data to a binary file using C

A few hints (not a complete solution): The fact that tm->tm_mon is zero-based and thus requires +1 to make sense as a month number jan…dec, does not mean that you must write sizeof(tm->tm_mon+1). In the same way, if you want to write its value and take its address, that does not mean you have to … Read more