|
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++
|
|
|
|
|
hi,
Can anybody tell me the proper syntax of using regular expressions in vc++ along with a sample code..which is the haeder file to be included to use the regex class? i got a sample code from mdsn..but it is to be compiled in command prompt..is there any other option to use regular expressions not using command prompt?
thanks,
rm
|
|
|
|
|
RegEx is .NET framework library class you need support for /CLR to get compiled as managed C++ code. in VC 6.0 I think it is not possible,
you may search for any C++ implementation available in Web, you can also check [Boost.Regex^] not sure.
|
|
|
|
|
Hello dear friends,
I've browser plugin(toolbar) application & using VC++ 6.0.
I've included a dialogbox resource in the resource file and a class for this dialogbox.
When I use DoModal() to display the dialogbox the GetLastError() returs
"Error BC31019: The specified image file did not contain a resource section"
The problem here is i don't understand.In the text mode the resource
script shows all the things right.Please help me out.
ritz1234
|
|
|
|
|
first test whether ur program initilazing com library. that is coinitialize(NULL).
let me give some piece of code if above method is not solved.
|
|
|
|
|
Are you working with any icons?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I created a MFC Regualr DLL using shared MFC. DLL contains 4 functions which are exported using __declspec(dllexport). Now in the client application i tried to make use of this DLL. two of exported functions are imported using __declspec(dllimport). They are working fine.
Now i tried to make use of third function using LoadLibrary and GetProcAddress. This time i am getting NULL pointer instead of function pointer. Again i placed extern "C" while exporting the function and tried to make use of it.This time i am getting the function pointer and every thing is fine.
Usage of extern "C" makes it work fine. Can any one explain me what actually happening here?
Thanks in advance...
|
|
|
|
|
Because your two first functions probably don't have any arguments. When you are using extern "C", it means that the function should be exported as a C function. In C, there is no function overloading so a function is identified only by its name. In C++, you can overload a function (a function with the same name can have different arguments). Which means that the name is not enough to identify the function. Thus, in C++ is introduced what is called name mangling: the types (and number) of parameters of the function are also used to identify the function. When you use GetProcAddress, you need to use the mangled name of the function (if there's no argument, the mangled name is the same as the function name).
So, by using a C function, you avoid the name mangling.
Hope it makes sense.
|
|
|
|
|
__declspec(dllexport/dllimport) uses C++ naming convention, so that the name exported from the dll is name mangled with C++ language convention, so when you try to get the address of the exported function using GetProcAddress(), the function name string won't match with name of the exported function which is decorted with c++ style, when using extern "C" linkage specifier naming convention used is that of C language which has the same undecorated name as that of the function.
|
|
|
|
|
Hi,
It is very clear now.
Thanks for your reply.
|
|
|
|
|
If you don't use extern "C" the name of the function is mangled the C++ way (you can see this effect viewing your DLL with Dependecy Walker ). That means you need to pass the mangled name to GetProcAddress() .
On the other hand, using extern "C" makes the function have C linkage, hence, roughly speaking, without mangling.
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
|
|
|
|
|
HI,
I got the point.
Thanks for your reply.
|
|
|
|
|