Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 months ago.
Improve this question
By using the Win32 API in C, I am trying to open a file explorer and make the user select an file, for which the absolute path will be put into some other function.
I have looked at Microsoft's resources [1-2], in order to try to utilize CoCreateInstance. However, they specify that five inputs should be given, while every other example, both in [1] and in [2], only gives four inputs. Compiling with only four inputs gives me an error in MinGW's GCC.
How can I create retrieve the absolute path from a file that the user specifies through the file explorer?
Moreover, is it possible to apply a filter to the file explorer such that only specified files can be seen? I can only see that this is possible in C#, and not C [3].
How can I create retrieve the absolute path from a file that the user specifies through the file explorer?
When calling CoCreateInstance(), you have to give it 5 parameters. The IID_PPV_ARGS seen in many examples is just a preprocessor macro provided for convenience to generate the last 2 parameters in a type-safe manner, but it is not a requirement. You can supply the last 2 parameters manually, as long as you are careful with them. For example:
IFileDialog *pfd = NULL;
CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd));
Is really just the same as this:
IFileDialog *pfd = NULL;
CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, __uuidof(IFileDialog), (void**)&pfd);
Aka:
IFileDialog *pfd = NULL;
CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_IFileDialog, (void**)&pfd);
Moreover, is it possible to apply a filter to the file explorer such that only specified files can be seen?
Yes. Use the IFileDialog::SetFileTypes() and IFileDialog::SetFileTypeIndex() methods.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
Let me start by saying that I'm a beginner programmer that knows very basic C
The exact code I'm working on doesn't matter here its just that I've run into a very odd problem (I'm messing around with ASCII graphics)
I want to differentiate between two 'O' characters. I could just use different characters but I want it to look good. I tried using Unicode to differentiate them (since Latin O and Greek Omicron look the same) but it won't work if I send it to someone else (since my output is on command prompt) edit: won't work if I send it to someone since command prompt must be manually configured to allow unicode characters (atleast to my understanding)
I don't know if using structures would work and I want to write this in C and not any other OOP language like python (because I'm practicing C)
So is there any logic I could use to do this?
EDIT: I want to apply different behaviours to both O and there will be multiple O of each type on screen (ik this is what objects do but pls help me with a logic for C)
EDIT 2: Apparently my question is very vague so I'll elaborate
I'm having a 2d array that I'm using as a game screen
I want O to come in from each side (top bottom right left), scroll across the screen and exit from the other side
I already came up with the logic to make it work for a single side but the problem comes in when I want to make it work for all sides
My current logic can't differentiate between an O that has to go left and and O that has to go down
Hence why I want to different between two instances of O
(I haven't posted my code since I just need the logic and want to solve the actual code by myself and also it's probably very inefficient or convuluted etc)
tldr: I want to differentiate between "O" and "O"
My current logic can't differentiate between an O that has to go left and and O that has to go down
Your problem is that you don't differentiate internal representation and external presentation.
You have two distinct objects that move across the screen. They both look like an O character. This doesn't mean your program should store them both as 'O', some variation of 'O' such as the omicron character. The program can store e.g. numbers 1 and 2, or any two different objects that are convenient to work with, and display an O in place of either.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
When I create a symbol layer the text field is wrapped if the text becomes too long. I'm not able to figure out why/when the text is to long. It seems to depend on different things e.g. font type, text size and text length.
I tested the text length by using this example code. I replace Cafeteria with the alphabet with space between each character. It then wraps to a second line between m and n and that's to few letters on one line for our use case. https://azuremapscodesamples.azurewebsites.net/Symbol%20Layer/Formatted%20text%20field.html
I have been working with mapbox. They have a setting "text-max-width" that solves this issue.
I have checked the javascript code that comes with the npm package azure-maps-control and it doesn't implement support for "text-max-width".
Do anyone know how to fix the wrapping issue or if the package azure-maps-control are going to implement support for the "text-max-width" setting?
There is no option for this today, but I've added it to the feature request list. As a work around, you could do the following:
var layer = new atlas.layer.SymbolLayer(datasource);
map.map.setPaintProperty(layer.getId(), 'text-max-width', 15);
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I wanted to clear my entrybox in order to when I want to enter something again it's clear.
I implemented a Simple Webbrowser.
In the entrybox is always the url but what I was looking for is that if i click (activate) the entrybox, the entrybox should be cleared.
I hopped I could do something like this:
if(gtk_window_get_focus(GTK_WINDOW(w->window)) == w->entry)
gtk_entry_set_text (GTK_ENTRY(w->entry), "");
But I don't realy know where to do it and how this wokrs that it can detect that the entrybock was clicked.
There are a couple of ways, but before we start: user may want to copy URL, clearing it on click event may be confusing.
Connect to parent class "grab-focus" signal
Use gtk_entry_set_placeholder_text to make text a placeholder (appears as slightly shadowed)
Conforming to the note above: set a secondary icon (gtk_entry_set_icon_from_icon_name, icon "edit-clear-symbolic") and connect to "icon_press" signal.
Complementing Alexander's answer ...
In case you don't know to associate callbacks with signals, you can use g_signal_connect(). This takes four parameters:
the object we are interested in - we need to use G_OBJECT() to cast this to the relevant type
the signal we want to watch - in this case grab-focus
the callback to invoke when the signal is raised
arbitrary user data (probably not needed in this case).
In this case you could call it like
g_signal_connect(G_OBJECT(w->entry), "grab-focus", G_CALLBACK(on_input_focus), NULL);
If you check the signature of the the callback for the grab-focus signal you will see it accepts two arguments and returns nothing. The last argument is the arbitrary user data which was the last parameter in the g_signal_connect() function; we did not set it and can ignore it. The first argument is the widget on which the signal was triggered - which we can cast to a GtkEntry.
void on_input_focus(GtkWidget *w, gpointer data) {
gtk_entry_set_text(GTK_ENTRY(w), "");
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Hi friends I was working on a project where we need to use quite a few multidimensional arrays. I am using for loops to access different array elements, then I just thought what if I don’t have a liberty to use looping? How am I going to access array element?
I am new to C, so thought of discussing here, I am sure there might be thousans of people who could have thought the same way, and hopefully found the solution.
Below example of multidimensional array is give, please guide me.
Thanks
static int t[3][2][4] = { {2,4,3,6,
1,6,7,9,},
{8,2,1,1,
2,3,7,3,},
{1,6,2,4,
0,7,9,5,},
};
Please Help me...thanks!
If you need to go through all of the values inside the loop without manual handling (i.e. x = t[1][1][1] then x = t[1][1][2] etc) then you want to use loops, enhanced loops or iterators. However since you're using C the only of those three options available are standard loops, which you're trying not to use. So... there's mo straight forward way to do that really.
If you're willing to use some other C libraries however then there may be more options for you. Iterator libraries probably exist.
A non-straightforward way to do it (if you're looking for one) could be through recursion, however that's really quite wasteful. I advise you just use loops :P
What are you trying to prove with loops and without loops should be first thought.
If u want to access all the elements and not use loop is like writing a lot of code manually and waste of memory(in your case 3 * 2 * 4 no of lines instead of few ).
Instead of showing the array if you had put in your code how and where you accessing elements it would have been more clear to tell what you wanted .
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
in my application i read a file, calculate its MD5 hash, cypher it with AES128 and write it inside file comments.
Thats because i need to ensure that file is not manipulated.
Sadly, when i write something inside file's "comments" properties its MD5 change and my work become useless.
So, i want to read my file excluding file's properties and only then calculate my HASH.
Now i read my file with this function:
function MD5File(const FileName: string): string;
var
IdMD5: TIdHashMessageDigest5;
FS: TFileStream;
begin
IdMD5 := TIdHashMessageDigest5.Create;
FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
Result := IdMD5.HashStreamAsHex(FS)
finally
FS.Free;
IdMD5.Free;
end;
end;
How can i get the "file properties" size? i suppose they are on the header OR the footer, so if i know the size i can exclude the first or the last part of the file
edit:
more information: i store the information manually editing the file properties (right click -> properties)
i too suppose that editing those information must not alterate my MD5.. but it does for some reason!
I read the file AND calculate its MD5 with the function in my post.
My problem is that when i write any value inside the comment the file's hash change and i'm writing a string based on file hash.
i think i will just wipe the "comment" properties before calculate hash.
Your premise is wrong. The "Comments" data you are entering is stored within the file in the EXIF part of the .JPG file. It does not have a fixed offset, so it's not easy to exclude it from your hash. You'll need to parse the .JPG file and manually skip over the portions of the file that you do not want to include in your hash. Read up on .JPG files and EXIF information stored therein.
Or rethink your premise. If you simply want a hash over the image portion, you can load the image as a TBitMap and iterate over all the pixels in the image (a very slow process) and include their colour code in your hash, thus excluding any data that isn't an actual part of the image itself.
Both these methods will mean that you can't do what you are attempting on anything other than files for which you know the file format (unless they are all image files that you can load into a TBitmap and thus only include the pixels in your hash). You cannot, for example, allow people to change comments or other things in f.ex. Word documents or PDF documents, unless - again - you read the file manually and only calculate a hash over the parts that you don't want to allow people to alter.