|
hi naveen,
here is he code
extern "C" __dllspec(dllexport) void CallDate()
{
AFX_MANAGE_STATE( AfxGetStaticModuleState());
CDateTimeDlg DateTimeDlg;
DateTimeDlg.DoModal();
}
thanks and regards
prashant
|
|
|
|
|
did u try removing that activex from the dialog?
where did u get this datetimectrl ActiveX? Is it the normal Date Time control among the windows common controls?
nave
|
|
|
|
|
hi nave,
it is Microsoft Date Time Picker control.
open VC++ go to dialog editor ,
right click, you will get a menu,
select "insert Active X",
a list of Active x components will appear.
in the list select "Microsoft Date Time Picker Control".
i have tried to remove the active X component and calling the DLL dialog.
then the dialog appears,works fine.
i suspect that acive x is causing the problem
thanks and regards
prashant
thanks and
|
|
|
|
|
ok I got the pblm. Put AfxEnableControlContainer(); in the InitInstance() function of the dll and then try.
nave
|
|
|
|
|
hi naveen,
i tried by adding AfxEnableControlContainer(); in the InitInstance() function of the dll . it didn't work.
if you have code sample. pls give it to me.
prashant
|
|
|
|
|
send me your mail id...
nave
|
|
|
|
|
hi naveen,
here is my mail id
pissey123@indiatimes.com
thanks and regards
prashant
|
|
|
|
|
I"m building a screen reader for my college project and I need to detect
words by the cursors position. Active Accessibilty(aac) is doing the job
well, but it gives me a full sentence and not the specific word in the
sentence where the mouse coursor is pointing at. For the ability to get this
word I need the Font properties, mainly width and height, of this acc
object. I need something like GetTextExtent but for the AccObject.
So how can I get the Font properties of an ActiveAccessibilty Object?
|
|
|
|
|
Hi to everyone, i have this code that tansform an IlpImage* in a bmp format..
char* bitmap_buf;
IplImage* image;
BITMAPINFOHEADER InfoBitmapHdr;
BITMAPFILEHEADER BitmapHdr;
image=cvLoadImage("nome_file.ext",1);
memset(&InfoBitmapHdr, 0, sizeof(BITMAPINFOHEADER));
memset(&BitmapHdr, 0, sizeof(BITMAPFILEHEADER));
InfoBitmapHdr.biWidth = image->width;
InfoBitmapHdr.biHeight = image->height;
InfoBitmapHdr.biSize = sizeof(BITMAPINFOHEADER);
InfoBitmapHdr.biPlanes = 1;
InfoBitmapHdr.biBitCount = 24;
InfoBitmapHdr.biSizeImage = image->imageSize;
BitmapHdr.bfType = 0x4d42;
BitmapHdr.bfSize = (DWORD) image->imageSize + sizeof(BITMAPFILEHEADER);
BitmapHdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + InfoBitmapHdr.biClrUsed * sizeof (RGBQUAD);
bitmap_buf= new char[image->imageSize];
memcpy( bitmap_buf, (char*)&BitmapHdr, sizeof(BITMAPFILEHEADER));
memcpy( bitmap_buf + sizeof(BITMAPFILEHEADER), (char*)&InfoBitmapHdr, sizeof(BITMAPINFOHEADER));
memcpy( bitmap_buf + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER), (char*)image->imageData, image->imageSize - 60);
Can you tell me which variable must i use to visualize the bmp in a picture box of a window form application in visual c++??
Thanks for answers, regards.
|
|
|
|
|
You have all the info you need to use CreateDIBSection() to create a HBITMAP that can be set to
a picture box.
Even without a picture box, you could use StretchDIBits() with a BITMAPINFO and a pointer to
the image bits to draw the image diectly on a window.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks Mark, i see form msdn the definition of hBitmap = CreateDIBitmap(hDC, lpInfo, CBM_INIT, lpBits, lpInfo,wUsage); but i can't associate my variable to that are required in the function. For example hdc(where is in my code??), lpinfo( InfoBitmapHdr.biWidth),CBM_INIT,lpbits(??),lpinfo(InfoBitmapHdr.biHeight),wUsage(??)
Thanks for answers, regards.
|
|
|
|
|
A BITMAPINFOHEADER is part of the BITMAPINFO struct required by CreateDIBSection().
The HDC is only used for bitmaps requiring a color table. The palette selected into the DC
is used by CreateDIBSection() to construct a color table when necessary. Since you have 24-bit
pixels it's not needed. You can use a screen DC.
I haven't used IplImage but based on what I've seen, the imageSize member is the size of just
the pixel data, not pixel data with Windows BITMAPINFO stuff attached. If I'm wrong you'll
have to adjust the following code a bit
Here's a modified version of your sample code. Note that this code is hardwired for 24-bit
images...
BYTE* bitmap_buf;
IplImage* image;
BITMAPINFO bmi;
image=cvLoadImage("nome_file.ext",1);
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = image->width;
bmi.bmiHeader.biHeight = image->height;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 24;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = image->imageSize;
HDC hdc = ::GetDC(0);
HBITMAP hBitmap = ::CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &bitmap_buf, NULL, 0);
::ReleaseDC(0, hdc);
if (hBitmap)
{
memcpy( bitmap_buf, image->imageData, image->imageSize );
...
}
*EDIT*
I looked up the IplImage structure. I'm not sure what the default alignment of rows of pixel
data is in OpenCV, but for a Windows DIB, rows must be aligned to a DWORD (4-byte) boundary.
If this does not match the IplImage alignment (based on image->widthStep) then your resulting
bitmap will look skewed
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks for answers,it's very useful.
There's a prolem when i try to compile:
HBITMAP hBitmap = ::CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &bitmap_buf, NULL, 0);
generate error C2664: 'CreateDIBSection' : cannot convert parameter 4 from 'BYTE **' to 'void **'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
so i try to do a safe cast, i add this line before the CreateDIBSection
void* buff=safe_cast<void *="">(bitmap_buf);
and use &buff instead of bitmap_buf in CreateDIBSection but the result is a list of build error:
error LNK2028: unresolved token (0A0002FA) "extern "C" int __stdcall ReleaseDC(struct HWND__
*,struct HDC__ *)" (?ReleaseDC@@$$J18YGHPAUHWND__@@PAUHDC__@@@Z) referenced in function "private: void __clrcall WinCam::Form1::capimgbut_Click(class System::Object ^,class System::EventArgs ^)" (?capimgbut_Click@Form1@WinCam@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
WinCam.obj : error LNK2028: unresolved token (0A0002FB) "extern "C" struct HBITMAP__ * __stdcall CreateDIBSection(struct HDC__ *,struct tagBITMAPINFO const *,unsigned int,void * *,void *,unsigned long)" (?CreateDIBSection@@$$J224YGPAUHBITMAP__@@PAUHDC__@@PBUtagBITMAPINFO@@IPAPAXPAXK@Z) referenced in function "private: void __clrcall WinCam::Form1::capimgbut_Click(class System::Object ^,class System::EventArgs ^)" (?capimgbut_Click@Form1@WinCam@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
...and so on.
I don't know why...
Thanks however for help.
Regards.
|
|
|
|
|
How to do a listbox that have columns in different width?
|
|
|
|
|
You can use CListViewCtrl if you want more than one column with different width.
For more information on how to use it, Search google.
Anurag Gandhi.
|
|
|
|
|
Is CListViewCtrl same as CListCtrl?
|
|
|
|
|
Im not sure but I think I saw like your answer some time ago and I answered to its question with an example(I think it was with CListCtrl) search on the Search comments.
|
|
|
|
|
I would like to resize a group box control during run-time (for instance in the OnInitDialog function). I only need to change it's height (make it smaller).
How can I do this?
I tried the following (which didn't work..):
CRect rect;
GetDlgItem(IDC_STATIC_GRP_SEARCH)->GetClientRect(rect);
rect.SetRect(11,280,66,280);
rect.DeflateRect(0,0,0,rect.Height()-50);
SetRect did not work so I tried using DeflateRect - and that also did not work.
Please help...
|
|
|
|
|
You're changing a RECT , but you still need to change the size of the control. SetWindowPos() will do that.
|
|
|
|
|
Then set the modified rect back to the control. Use either of;
SetWindowPos
MoveWindow
--
=====
Arman
|
|
|
|
|
I don't understand - do I have to call setRect and afterwards call setWindowPos or MoveWindow, or do I not need to call setRect?
I tried adding a call to setWindowPos as following:
CRect rect;
GetDlgItem(IDC_STATIC_GRP_SEARCH)->GetClientRect(rect);
rect.SetRect(11,280,66,280);
MoveWindow(11,280,198,66);
but it just ends up changing the size of the whole dialog and not the control itself....
if you could please write an example of the code it would be very helpful.
|
|
|
|
|
Even no need to the get the client rect in your case; this is because you specify absolute coordinates; I mean not depending on the current position of the control.
GetDlgItem(IDC_STATIC_GRP_SEARCH)->MoveWindow(11,280,198,66);
--
=====
Arman
|
|
|
|
|
I have currently got a menu, which I loop through all the items to make them owner drawn (including sub-items) using ModifyMenu(), however, the menu bar doesn't get custom drawn, and no WM_DRAWITEM message is invoked for it. Is there a way that I can draw over the remaining menu bar or make it owner-drawn aswell?
Thanks for your help!
--PerspX
|
|
|
|
|
Hi,
Please send the code so we can trace where exactly the mistake is.
Anurag Gandhi.
|
|
|
|
|
Well, basically, there is the main window, which is "captionless", then there is a child popup window on top of it, which is also captionless, which has the menu in it. When the menu is drawn in this second window, it spans the entire width of the window, so leaves some un-drawn areas which don;t get covered by the WM_DRAWITEM message.
This is the code to make the menu items owner-drawn, and this works fine for all of the menu items, and sub-items, but it DOESNT custom draw the actual menu bar which is left showing.
HMENU hMenu;
int i, x;
for(i=0;i<GetMenuItemCount(hMenu)+1;++i) {
buffer=malloc(10); //Allocates some memory for the menu item text
LPCTSTR text=(LPCTSTR)GlobalAlloc(GPTR, 10); // Allocates memory to set the itemData property of the menu item
GetMenuString(hMenu, i, buffer, 10, MF_BYPOSITION); //Gets the menu text
text=buffer; //puts the menu text into the LPCTSTR variable
ModifyMenu(hMenu, i, MF_BYPOSITION | MF_OWNERDRAW, 0, text); //Makes the menu item owner drawn and sets the itemData to the menu item text
hSubMenu=GetSubMenu(hMenu, i); //Finds the submenu of the menu item
if(IsMenu(hSubMenu)) { //Checks if it really is a submenu
for(x=0;x<GetMenuItemCount(hSubMenu)+1;++x) { //loops through all submenu items
subBuffer=malloc(30); //allocates some memory
GetMenuString(hSubMenu, x, subBuffer, 30, MF_BYPOSITION); //Gets the text
ModifyMenu(hSubMenu, x, MF_BYPOSITION | MF_OWNERDRAW, 0, (LPCTSTR)subBuffer); //Sets the owner drawn style
}
}
GlobalFree((LPSTR)text); //Frees memory
free(buffer); //Frees the memory
}
Thanks for your help!
--PerspX
|
|
|
|
|