|
How to load swf from resources? any tutorial or steps ?
There are functions to load icon and dll but what to do with swf.
Is it possible?
|
|
|
|
|
You can get a resource into memory (as if you'd read it from a file) like this:
std::vector<BYTE> LoadFileFromResource(HINSTANCE hmodResource, LPCTSTR name, LPCTSTR type)
{
if (!type)
type = ::PathFindExtension(name) + 1;
HRSRC rsrcFile = ::FindResource(hmodResource, name, type);
if (!rsrcFile) return std::vector<BYTE>();
HGLOBAL gblFile = ::LoadResource(hmodResource, rsrcFile);
if (!gblFile) return std::vector<BYTE>();
DWORD sizeFile = ::SizeofResource(hmodResource, rsrcFile);
if (!sizeFile) return std::vector<BYTE>();
LPVOID filePointer = ::LockResource(gblFile);
if (filePointer)
{
return std::vector<BYTE> contents((BYTE*)filePointer, sizeFile);
::FreeResource(gblFile);
return contents;
}
return return std::vector<BYTE>();
}
I take a copy of it here, to make resource management easier, but you don't have to do that...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
YOu can also use the res://[^] protocol, which basically gives you an URI for the resource element.
|
|
|
|
|
Hello folks!
I have a few layered windows which use per-pixel alpha of 32 bit bitmaps to display graphics. I use WindowFromPoint and TrackMouseEvent (which probably uses WindowFromPoint also somewhere along the way of its processing but that's just a guess) to know when the mouse points at these windows. Now, here comes the catch, WindowFromPoint takes the alpha channel of layered windows into acount (also TrackMouseEvent does this when listening for mouse-leave events), so when the given point (e.g: mouse position) is above a transparent pixel of the window then it will ignore the window. This is very good that way 99.9% of the time. However, i would need WindowFromPoint and TrackMouseEvent to handle my layered windows as if they were not layered windows, so they were normal, everyday, non-transparent rectnagular windows. Is this trick possible somehow? I know i could just forget about these methods and try to write my own implementations, enumerating windows, checking Z-orders and so on to try and find the "pointed" window, but it is probably quite a hassle to implement and would probably turn up a lot of "i didn't think of this" cases when it fails.
Thanks in advance for any comments, ideas, answers.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
|
Hey, thanks for the suggestion, however, my layered windows are popup windows, not child windows (as far as i know you can't have layered child windows at all), and i believe the CWP_SKIPTRANSPARENT flag of ChildWindowFromPointEx refers to the WS_EX_TRANSPARENT window style rather than any transparent pixels in the window. Correct me if i am wrong.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Hi,
Well popup windows are usually children of the dektop window so that really isnt an issue. I just did a quick test with one of my applications splash screen and was able to use ChildWindowFromPoint to find my popup splash using the desktop as the parent. The bad news is that I confirmed your suspicion about WS_EX_LAYERED windows with an alpha. ChildWindowFromPoint did not find the window when I hovered over transparent regions.
Best Wishes,
-David Delaune
|
|
|
|
|
I thought of doing the following: I call WindowFromPoint, if it returns one of my windows then the case is clear, if it does not, then i enumerate my windows, check if the point lies inside their window rectangles, if i find one then i check if the window WindowFromPoint returned is above or below my window (in Z-order i mean) and if it is below then i assume the point is in my layered window, otherwise not. This involves finding the popup that contains the window WindowFromPoint returned in case it is not a popup itself, i guess that can be done easily unless GetParent and GetWindowStyle (GetWindowLong and GWL_STYLE) does not work for windows of different processes (have to check that)...
What do you think? Thank you for your oppinion.
Sadly this does not solve the TrackMouseEvent problem...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Hi,
Sorry about the long reply delay. Today is Sunday and I am being very lazy.
Code-o-mat wrote: What do you think? Thank you for your oppinion.
Code-o-mat wrote: Sadly this does not solve the TrackMouseEvent problem...
Well in my opinion you should find a solution which addresses both issues. Have you tried the following?
POINT p;
GetCursorPos(&p);
LRESULT r = ::SendMessage(aboutDlg->m_hWnd,WM_NCHITTEST, 0,MAKELONG(p.x,p.y));
I tested this on a splash screen which is WS_EX_LAYERED and has an transparent alpha color key. The WM_NCHITTEST is returning HTCLIENT for anything inside the window rect *including* transparent region.
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: Sorry about the long reply delay. Today is Sunday and I am being very lazy. Sleepy
No need to say sorry, i apriciate you take the time to help, may that be in 1 minute or 3 days, so thank you.
Randor wrote:
POINT p;
GetCursorPos(&p);
LRESULT r = ::SendMessage(aboutDlg->m_hWnd,WM_NCHITTEST, 0,MAKELONG(p.x,p.y));
I tested this on a splash screen which is WS_EX_LAYERED and has an transparent alpha color key. The WM_NCHITTEST is returning HTCLIENT for anything inside the window rect *including* transparent region.
I tested this, but this kinda works the same "is the point inside the rectangle" way and it will return HTCLIENT even if the window is overlapped by another one, so if there is a window covering the one i test for and the point is inside its window rectangle it will report HTCLIENT althorough the mouse points at a different window.
I guess i will have to rethink the way i want to implement this, forget about TrackMouseEvent and either use a global mouse hook to track the nouse's position, use a timer to periodically poll the position (i personally dislike polling) or use SetCapture when the mouse enters a window so i can track where it goes and notice when it leaves. For the hit-testing i probably will try the WindowFromPoint + check Z order + check rectangle (WM_NCHITTEST for that seems to be a good idea, thanks) "trio".
A simple aproach to the problem which works both for WindowFromPoint and TrackMouseEvent is to change all the alpha values in the bitmaps that define the layered windows to be at least 1 (so no zeroes, no completely transparent pixels), as it seems hit testing by windows with layered windows is based ont he alpha pixel value, if the pixel has a 0 alpha value (completely transparent) then there's no hit, otherwise there is. I just don't know how reliable this method is and also if it can produce any noticable visual anomalies (a "ghosty" rectangle around the bitmap"). For now i will just take this for simplicity, althorough i don't much like it...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
modified on Monday, May 10, 2010 6:23 AM
|
|
|
|
|
How to get System Time Zone?
|
|
|
|
|
|
|
I was using Afx earlier on in my project!
But since I hate MFC, I rewrote the segments that were using the CFile and replace them with WriteFile.
However when I decided to remove the Afx.h header.
It gave me an error during recompilation.
1>main.obj : error LNK2001: unresolved external symbol __imp__SHStrDupW@8
1>C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Win32\Release\Win32.exe : fatal error LNK1120: 1 unresolved externals
Since the SH reminded me of the shell APIs I looked up the function.
SH String Duplicate, which I'm not using at all in my code.
|
|
|
|
|
maybe the 'depends' MS tool will tell you what your dependancies actually are - obviously something in your code or being used by your code is using this
'g'
|
|
|
|
|
Well I got my hands on the application!
But I don't know where to start.
Tried profiling, but it is halted by these errors.
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
|
|
|
|
|
It's a link error, so everything compiled correctly (you're including the correct header). The linker can't find the definition of the function SHStrDup ; looks like you not linking to the correct import library. A quick look at the docmentation shows that you should be linking to "Shlwapi.lib". Either add it to the list of libraries you're linking to or add the following line somewhere:
#pragma comment(lib, "Shlwapi.lib")
Steve
|
|
|
|
|
hi,
I need to do language localization using XML in VC++ (MFC).
I need to do mapping using XML file and i need to scan the XML file for the desired language, so that my output would be in my desired language.
I have no idea, how to go about it.
Please Support.
Thanks,
Punyah
|
|
|
|
|
You know that you need C++ and XML but have no idea on how to do it? That's funny, IMHO.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes, because got some guidelines from my manager that it will be done using XML and the project is already in MFC vc++. so, will you please help, if u can.
Thanks.
|
|
|
|
|
Well, you may create XML files similar to string tables, with each language you support having it's own (or more than one) XML table.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
A better approach that xml is explained in this article:
Resource DLLs and Language Selection Menu[^]
If nothing else, reading that article will help you understand some of your challenges.
With xml, you'll have to parse it, and change the text in every element in any dialog manually... Your code will be brittle.
I hope your manager has some cunning plan in mind. Or has he just heard that xml is a good storage method? And likes buzzwords?
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
DWORD cchData = MAX_VALUE_NAME;
char* achData;
if (!RegGetValue(hKey, NULL, L"Left", RRF_RT_REG_SZ, NULL, achData, &cchData))
xPos = atoi(achData);
Only getting 1 character! The first on the far left.
|
|
|
|
|
you have to provide a buffer that's big enough to hold the data from RegGetValue. an uninitialized pointer isn't enough.
|
|
|
|
|
tried
char achData[MAX_VALUE_NAME];
But still only one character!
|
|
|
|