FindResource() doesn't find my resource - c

I have some code template that i compiled, i would like to understand one part of the code that i am can't figure out what it does although i have spent a whole day tried to.
the code in question is as follows:
#define IDR_STUB 1
hRsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_STUB), "STUB");
I have another two files in the same directory as the main file, the first one is called `something.rc' and is content is:
#define IDR_STUB 1
IDR_STUB STUB DISCARDABLE "stub.exe"
The other file as you can guess is stub.exe.
My question is what is wrong with the FindResource call above that it can't find whatever is trying to find, I have hard time to understand how that function is suppose to work.
So if you can give me some help i would be glad :)
THX.

Had the same problem. I solved it by using string resource id as described in MSDN:
If the first character of the string is a pound sign (#), the remaining characters represent a decimal number that specifies the integer identifier of the resource's name or type. For example, the string "#258" represents the integer identifier 258.
So try the following code:
hRsrc = FindResource(NULL, "#1", "STUB");

I've stuck in the same issue, when tried to use predefined resource type RC_DATA.
FindResource(hInst, MAKEINTRESOURCE(name), RT_RCDATA);
This code was returning NULL whatever I did.
So when you edit your .rc file you should use constant RCDATA, but when you call FindResource() you should use constant RT_RCDATA. Be careful. Hope I've helped someone.

Related

Error on one page that does not appear anywhere else

Hi so my wordpress site has just started acting up, I am not sure if its an update that has caused this but only on this one page I am getting this error regarding
Notice: Array to string conversion in /customers/c/1/7/veganantics.co.uk/httpd.www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/Schemas/ImageAttachmentSchema.php on line 95
I can't seem to find the issue, I have tried replacing the file with a new core file and the error is still there, would really appreciate some help
This is the page: https://veganantics.co.uk/vegan-gifts/
Thank you
Ash
The theme, a plugin or some custom code is probably using the wp_calculate_image_sizes filter and returning an array instead of a string.
Do a text search on your install and look for wp_calculate_image_sizes. The function that you need to find will look similar to
add_filter('wp_calculate_image_sizes', 'something');
Explanation:
ImageAttachmentSchema.php on line 95 is calling wp_get_attachment_image_sizes which must be a string.
wp_get_attachment_image_sizes is returning wp_calculate_image_sizes( $size_array, $image_src, $image_meta, $attachment_id ) which again must be a string.
wp_calculate_image_sizes returns a filtered value, and that's the only place where such an error (array instead of a string) can happen. So, if the filter incorrectly returns an array, it bubbles up to the function that you see in the error log.

Is there a way to sort a no. of character arrays in alphabetical order without using the #include<string.h> or #include<stdlib.h>?

So, I have tried to do the same in a case of array of structures where 'char name[100]' is the only data member.
1st part of the code
2nd part of the code
The problem that I have encountered here is that once I provide a no. of names during program runtime, the output screen either does not print anything afterwards, or, prints the data without sorting it.
output screen
I did not get any compile time errors so I believe that there is a flaw in the logic.
There's this another method I tried hoping to get positive results. I type-casted characters to integers hoping that ASCII values could be used to compare. But, the results are exactly the same (undesired results).
updated logic of the 2nd part of the code
I hope somebody helps me find a way to correct this logic or provide another logic that is efficient.
the sorting logic you used is good , but from what is see the use of function's in C need's to be provided by pointers. other wise all the data inside the function will born and die inside the function , and the all the variables in the Main will stay the same as given, that explains why the output is the same as the input
try to print inside the sorting function's to see if this is the problem.

How can we handle truncated label or text

In order to test few features of the application I need to validate long alphanumeric string. And this string/label/text (whatever you can call here) supposed to truncate once given by user.
I googled and tried to find - 'how to validate truncated string ' and did not find useful info so thought question should be here.
Challenge - I can write up a xpath for long string to validate the tag/label/text/string itself but complex part is string shows few dotes (ex thisIsLongStrin.....) at the end when got truncated.
I would like to make sure that these 'dotes' are displaying when long string is given by user.
Remember I can not see these 'dotes' in page source.
any thoughts or suggestions on this ?
Thanks guys in Advance.........!!!!!
suppose string is : "thisIsLongString"
on page it shows after truncating : "thisIsLongStri..."
this is what working:
//*[#class='abc']//*[contains(text(),'thisIsLongString')]
this is what working:
//*[#class='abc']//*[contains(text(),'thisIsLongStri')]
this is Not working :
//*[#class='abc']//*[contains(text(),'thisIsLongStrin...')]
(since dotes are not part of page)
I am not sure what should be the approach to make sure that these dotes are there.
Truncated text is the result of applying CSS property text-overflow: ellipsis. To check whether text truncated or not, you can use Selenium built-in method:
Python example
element = driver.find_element_by_xpath("//*[#class='abc']//[text()='thisIsLongString']")
assert element.value_of_css_property("text-overflow") == "ellipsis"
P.S. Of course you should also check (if you don't know for sure) whether string is long enough to be truncated as even if text-overflow: ellipsis property is applied, short string will NOT be truncated, so it might looks like
assert element.value_of_css_property("text-overflow") == "ellipsis" and len(element.text) > 20
This should check whether property applied and length of string is greater than 20 characters...

angular ui.mask for variable length format

i am trying to use angular ui.mask module to display a full length url based on user entering a section name(suffix)
http://www.example.com/XYZ where 'XYZ' is the user input.
While a mask 'http://www.example.com/AAA' works fine, it does limit the user to entering only 3 character.
Any quick ways to extend the length accepted?
I tried altering the regex to accept variable length, but haven't got this working.
Any help would be appreciated.
Thanks.
This can be accomplished by using a question mark before any character in the mask that would be optional.
In your case, it would look like:
ui-mask='http://www.example.com/?A?A?A?A?A?A?A?A?A?A?A?A?A?A?A?A'
Better late than never...

Validation rules in access

I recently started learning and using microsoft access. However, I am afraid that there is something really bothering me. It's connected with the validation rules. So here is my problem:
I had to validate a field so that only letters could be written. Of course I googled it and found the proper syntax. (Is Null or Not Like "*[!a-z]*")
At first I tried with (Is Null or Like "*[a-z]*"), which I think should be the same as the above one. It's checking every symbol from the string whether it is between 'a'and 'z' and that is why it is used with the obelisk * symbols from the both sides. Am I right?
My question is: Why is the second one not working, although it is a double negative equivalent to the first one. Will be happy for any explanation. Thanks in advance!
P.S Sorry if the question seems useless for you but I really do want to figure out where I am mistaking.
Consider the string 'a1b'.
Like "*[!a-z]*" will search the string for any character that is not in the range 'a'..'z'. It finds the '1' in the second position and returns True. Therefore, Not Like "*[!a-z]*" returns False.
On the other hand, Like "*[a-z]*" searches the string for any character that is in the range 'a'..'z'. It finds the 'a' in the first position and returns True.

Resources