|
Sir,
I have tried with the code.But i get an error message as
"fatal error C1083: Cannot open include file: 'cvaux.h': No such file or directory"
Please do help me in doing the code.ie,how to arrange all the files..
|
|
|
|
|
Have you included the # include and the file with "Add to project" ?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
I have added all the files using "Add to Project".
It shows an error "missing file dshow.h"
"see previous definition of '_WIN32_WINDOWS'"
|
|
|
|
|
Hello,
I have an windows application that has been working for about a year.
It consists of an application that uses dlls to provide localized langauge support. Each dll simply contains the dialogs used in the main app but with the text translated. They also contain the resource.h file.
I have recently made some updates to the main app which have required new buttons and text on the dialogs. The same changes have been made to the dialogs in the dlls.
When I run the app and select an alternate language the appropriate dll is loaded. However a call to GetDlgItem fails because it cannot find the Resource ID listed as it's argument. I know this ID exists, and in fact have placed the offending code within #ifdef just to prove that the symbol is indeed defined.
The same resource ID names are used in both the main app and the dlls.
When using the mains apps dialogs (english) all is fine, but when using the dialogs loaded from the dll a NULL pointer is returned by GetDlgItem.
The call to getDlgItem is not new and has been working fine until now.
Can anyone offer any insight?
The code is listed below. Originally I had this all on one line as per the line commented out. However I have expanded to debug.
Cheers
Rich
Static* pItem;
#ifdef IDC_STATIC_OTHER_CURR
pItem= (CStatic*) GetDlgItem(IDC_STATIC_OTHER_CURR);
if(pItem == NULL)
{
}
else
{
pItem->GetWindowPlacement(&wpa);
}
#endif
|
|
|
|
|
kildareflare wrote: The same resource ID names are used in both the main app and the dlls.
Can you check ,although the ID names (MACROS) are same, the values of the IDs are same. I mean IDC_STATIC_OTHER_CURR in exe may be 100 while in dll it may be 200.
|
|
|
|
|
Hi Rajkumar
Yes it has the same ID number in both and the name is identical too.
Rich
|
|
|
|
|
The actual location of the failure is in the function below
BOOL CWnd::GetWindowPlacement(WINDOWPLACEMENT* lpwndpl) const
{
ASSERT(::IsWindow(m_hWnd));
lpwndpl->length = sizeof(WINDOWPLACEMENT);
return ::GetWindowPlacement(m_hWnd, lpwndpl);
}
It fails at the ASSERT becuase m_hWnd cannot be evaluated
"unused CXX0030: Error: expression cannot be evaluated"
the following function call precedes the one above (see original post):
CWnd* CWnd::GetDlgItem(int nID) const
{
ASSERT(::IsWindow(m_hWnd));
if (m_pCtrlCont == NULL)
return CWnd::FromHandle(::GetDlgItem(m_hWnd, nID));
else
return m_pCtrlCont->GetDlgItem(nID);
}
In this case m_hWnd does have a value, so it's somehow lost between the two calls...? Like I say this has allways worked fine until now...
Rich
|
|
|
|
|
kildareflare wrote: In this case m_hWnd does have a value, so it's somehow lost between the two calls...?
no, GetDlgItem is called for your dialog (Parent) window, while GetWindowPlacement is called for the expected child window (static control) so m_hWnd is different and unique.
|
|
|
|
|
kildareflare wrote:
pItem= (CStatic*) GetDlgItem(IDC_STATIC_OTHER_CURR);
can you try get what is the error by,
::GetDlgItem(GetSafeHwnd(), IDC_STATIC_OTHER_CURR);
dwErr = ::GetLastError(void);
can you ensure whether the dialog resource is successfully loaded from dll, did you successfully displayed the dialog, from the next post of you, it seems the m_hWnd handle is not valid, means the dialog may be not successfully created from resource of dll, can you post how you create the dialog from dll resource. at which method of dialog class you are calling the GetDlgItem() function.
|
|
|
|
|
Error 1421 "Control ID not found" is the error reported.
The dll is loaded as follows:
if((CString)langID == LANGUAGE_SPANISH)
{
hInst = AfxLoadLibrary(_T("CalcESP.dll"));
if(hInst == NULL)
AfxMessageBox("Could not load CalcESP.dll");
}
AfxSetResourceHandle(hInst);
The handle hInst is valid and I belive the resource is loaded OK as some of the resource IDs are found OK - it's just some that are not. Is there a more precise way I can check what has been loaded?
To be honest I do not know dlls that well, however...
The appropriate dll is loaded in the applications InitInstance() function as shown above and then the handle retuned is used to set the default resouce location. Next views are created from doc templates and then the main MDI Frame window is created.
All dialogs are created using standard constructors - im assuming that they will use the default resource which has been set above.
The application would run and the dialogs load if I managed to comment out all the IDs that were "not found".
If I force the application to use the english hInst then everything works OK, as would be expected since this is the same as not changing the language.
However, if instead I copy the engligh dialog and resource.h file over the spanish ones - it has the same problem - even though it is now using the english resources which I know work OK and this is surely the same thing as forcing the application to use the english resouce path i.e hInst...?
Thanks again
Rich
modified on Tuesday, May 13, 2008 8:49 AM
|
|
|
|
|
kildareflare wrote: Is there a more precise way I can check what has been loaded?
see Iain clarke's reply below to use spy++, spy++ is a tool comes with visual studio tools you can get the window properties like control ID and verify the values using easy to use window finder tool.
|
|
|
|
|
In addition to the other suggestions, the NO_FAIL_CREATE style for a dialog is very useful. Then with a lot of commenting out, you can show the dialog, and (a) see if the static control is even there, and (b) using spy++ see if the ctrl id is the one you expect.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Hi Guys,
I was aware of Spy did not think it would be much use wihtout a window, thanks for the no fail create tip though as that takes care of that.
After considerable commenting out I now have the app up and running.
using spy I can see that virtually all the static controls have an ID of
FFFFFFFF (Chris Waddle ). On this particular dialog, all bar one of the static controls have this ID. All the Edit and button controls have sensible IDs that match the resource file.
So any ideas why they should all be FFFFFFFF?
Out of interest I just ran the default version of the app that has no problems to see what the IDs were listed as there. The majority of the static controls have sensible IDs however one or two were as above, FFFFFFFF, but in this case they caused no problems....
Rich
modified on Tuesday, May 13, 2008 9:24 AM
|
|
|
|
|
kildareflare wrote: So any ideas why they should all be FFFFFFFF?
FFFFFFFF -> -1 -> IDS_STATIC. Your dialog editor will use this by default for static controls, as they don't in general need an ID code. They're just lumps of text plonked on your dialog.
If you want to do something useful with them, then you'd need to add control with a UNIQUE (to that box!) ID so you can use the GetDlgItem function to turn the ID into a HWND/CWnd.
The IDE's dialog editor will complain about any non-unique id except for -1 (said with no actual testing done) which is why it is used.
So, now you know the issue, you can start putting "I'm spanish!" into your dialog boxes to makee sure you're loading the correct ones, and go through them checking that you have assigned IDs properly.
Straightforward, but not speedy work.
Iain.
ps, love the fast show reference, though I usually follow it by "Scorchio!" in my head.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Buone Estente ;0)
hehe - though it might be a long shot but could no resist.
Thanks for that Iain. Im a bit confused though. All these IDs that are being listed as FFFFFFFF do actually have unique IDs. I move all lot of them around depending on what "view" the user is currenlty using E.g. advanced/basic.
E.g. in all dialog versions (English, Spanish,...) there is a control called IDC_STATIC_OTHER_CURR with an ID 1464. So it's not generic and so the call to getDlgItem() should not fail, no?
In fact it's currently on these lines that it is failing. With reference to my original post, if I hover the ID that is the argument to GetDlgItem() then it's correct ID is displayed (E.g. 1464 or such). If it "knows" enough to know the ID has a value then I find it a bit baffling that it can't find it. Im also quite surprised to see them listed as generic FFFFFFFF's using spy.
modified on Tuesday, May 13, 2008 10:26 AM
|
|
|
|
|
No, I'm not espanol - just picking on one of them funny furrin' made up languages that those funny people who live elsewhere pretend they use, so they don;t have to listen to english, even when I use it slowly and LOUDLY.
I'd trust spy++ myself though.
Have you tried looking at the raw resource code, rather than using the pretty editor? Just use file, open, pick a resource file, and tell it its type is text.
Then change an ID or two to actual numbers, rather than IDC_BLAH.
I also meant it about putting some silly unique thing in each dialog, so you know which one that is actually being used.
It may also be that your static control has ended up with a text id, rather than numeric, but I'd have to go digging to find a decent example. That's why I'm suggesting you use an actual number for this test, to narrow things down.
Good luck - you have a fiddly problem.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
That it is - I can't belive how much time this is taking!
I've not used the resource file directly for changes, but have used it to check that everything is as I would expect.
As you suggest I've now changed an ID to a number:
LTEXT "Capacidad (A):",IDC_STATIC_CURR,6,160,72,9
LTEXT "Capacidad (A):",1500,6,160,72,9
This has made no difference though. Same error trying to locate the control. With regard to your suggestion to add something unique - unless ive misunderstood what you mean they are already quite unique - one dialog is in english the other in spanish....
|
|
|
|
|
I'm struggling to think of anything to suggest, except backing up your project, and getting rid of all controls except for one on this dialog(s), and grow forward from there.
Or maybe make a new pair of very boring dialogs - the choice is yours. When you have only one button on the dialog, you can do:
BOOL CMyTestDlg::OnInitDialog ()
{
CWnd *pChild = GetWindow (GW_CHILD);
int nID = 0;
if (pChild)
nID = pChild->GetDlgCtrlID ();
return CDialog::OnInitDialog ();
}
and see how that works. If it shows a proper ID number for each languages button, then change it to a static control, and check that. Then build out.
In addition - the fact that you needed DS_NOFAILCREATE is a clue that something funky is going on.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Hmm, yeah I was starting to think that building everything from scratch might be the way forward...
If I happen to solve it at some point along the way, i'll post it
Thanks to both of you.
Rich
|
|
|
|
|
Hello
I've found the cause of the problem. To be honest it's a little (well really quite) embarrasing, bit of a schoolboy error. But i think linked to my relevant in experience in windows programming, resource files and dlls!
There appears to have been two problems.
Firstly, these resource files are rather large and while the resource ID in question had the same number across all language variants, several others did not. The resource file also had several duplicated ID numbers.
Since Visual Studio itself was maintaining these and updating them I incorrectly assumed that was OK.
Once I became aware that this was not the case I used a utility to renumber them and ensure no conflicts (free from RiverBlade).
Secondly, even though I was making lots of changes to the resources and the application when debugged appeared to load them correctly I was not seeing any changes.
This was becuase Visual Studio appears to load all dlls from the system directory. I was expecting a debug build to use the debug output folder.
Even though I now know this I still often forget to copy the dlls across after a build. To get round this I have used the Post-Build feature found under Project Settings->Build Events->Post Build Event
In the command line I have placed a MSDOS command to copy all the dlls from the debug directory to the system32 folder.
Rich
|
|
|
|
|
Hello,
i have a problem with creating bitmaps out of a bytearray.
At first, I tell you what i'm actually doing.
I have a Camera class and an Imageprocessing class. The imageprocessingclass
is registered as a observer at the camera class. I connect with the Vfw cap drivers
to my webcam. In my Camera class, there is a static method that contains
the LPVIDEOHDR. In this method i call the Process method from Imageprocessing Class
with LPVIDEOHDR as parameter. That means, i can work with the LPVIDEOHDR structure
in my Imageprocessing class. My Dialog is also an observer registered at
Imageprocessing Class. In Imageprocessing Class i do some filter work and so on.
When the filter work is done i call a Update method from my Dialog with
unsigned char* pData as parameter. At the moment, pData contains greyscaled data.
I've already converted the RGB data to greyscale data in my Imageprocessing Class.
In my Dialog i have live view from my cam.
My Question is how to make a Bitmap out of the unsigned char array and display it
in my dialog on a certain position. I want to display it next to my live view.
I've already created a picture control frame next to the live view. so i can get
the coordinates where i want to display the Bitmap. The Imageprocessing Class permanently
calls the Update method from my dialog and gives the unsigned char array.
So, how to make a Bitmap out of this given bytearray and display it on my dialog next to the live view when my update method has been called ?
the Update method doesnt belongs to MFC or WinApi. My dialog derives from my observer interface and
has to implement the virtual Update method.
I hope havnt confused you too much.
greetings,
cmos
|
|
|
|
|
|
You should be able to use the code Rajkumar linked to.
After CreateDIBSection() succeeds, you can copy your 8bpp data
to the memory at pBitmapBits.
Important note: GDI DIbitmap data is always DWORD aligned for each row -
that means the row size in bytes (commonly called stride - the lBytesPerRow
value in my code) is always rounded to the next multiple of 4 bytes. You'll
need to take that into consideration when doing the copy
Once you've copied the pixel bits, you can use the HBITMAP (hBitmap) in your
picture control.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I've checked out lot s of examplse and code snippets but the problem is still there.
Can somebody help me please ?
My Bytearray contains Gray values.
My OnPaint Methode looks like
OnPaint()
{
if(isIconic)
{
CPaintDC dc(this);
...
...
}
else
{
CPaintDC dc(this);
CDC MemDC;
CBitmap Bitmap;
// what to do here?
CDialog::OnPaint();
}
}
I also had look at this thread here http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2539266
Well, I could compile it without errors. But where can i set my data ?
Just get a black square on my dialog. I am desperated.. Have been looking for hours for a
solution.
cmos
<div class="ForumMod">modified on Saturday, May 24, 2008 10:24 AM</div>
|
|
|
|
|
Are you letting a picture control draw the bitmap or are you rendering
the bitmap yourself?
If a picture control, then you need to set the control's image with the
STM_SETIMAGE message (not in OnPaint()!).
If you're rendering yourself, then in your OnPaint() code, select the created
bitmap into your MemDC then use BitBlt()/StretchBlt() to render the bitmap
from the memory DC to the paint DC.
cmos wrote: Have been looking for hours for a
solution.
Maybe hours that would have been better spent doing a little reading about basic GDI
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|