|
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
|
|
|
|
|
I've used the CreateDibSection function to create a DIB for bitmap...
HWND hWnd = this->GetSafeHwnd();<br />
HDC hdc = ::GetDC(hWnd);<br />
<br />
BITMAPINFO bmpInfo;<br />
<br />
ZeroMemory(&bmpInfo,sizeof(bmpInfo));<br />
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);<br />
bmpInfo.bmiHeader.biBitCount = 8;<br />
bmpInfo.bmiHeader.biCompression = BI_RGB;<br />
bmpInfo.bmiHeader.biSizeImage = 0;
bmpInfo.bmiHeader.biPlanes = 1;<br />
bmpInfo.bmiHeader.biHeight = 768;<br />
bmpInfo.bmiHeader.biWidth = 1024;<br />
bmpInfo.bmiHeader.biClrUsed = 256;<br />
<br />
hFrameBitmap = CreateDIBSection(hFrameDC, &bmpInfo, DIB_RGB_COLORS, &pBits, NULL, NULL);
I'm wondering how I can set the 4th parameter to point to a FILE* type which I store my raw pixel data, where pBits must be a LPVOID.
Thanks
|
|
|
|
|
bankai123 wrote: I'm wondering how I can set the 4th parameter to point to a FILE* type which I store my raw pixel data, where pBits must be a LPVOID.
you can't use a FILE*, but you can create a memory-mapped file, if you simply can't read that pixel data into memory:
HANDLE hFile = CreateFile(pFileName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
DWORD dwSize = GetFileSize(hFile, NULL);
HANDLE hCFM = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
LPVOID pData = MapViewOfFile(hCFM, FILE_MAP_READ, 0, 0, 0);
... and now pData is a pointer to the data in the file
UnmapViewOfFile(pData);
CloseHandle(hFile);
|
|
|
|
|
My project is about SDI that use CEditView is parent class(it look like NOTEPAD).
when user right click on client area the menu that including Undo, Cut, Copy, Paste, ... will pop up.
I want to add another item to here.
Please give me some idea for do this.
|
|
|
|
|
Hi Max,
you can override OnRButtonDown event.
Create your own menu and display it when Right mouse button is clicked.
Anurag Gandhi.
|
|
|
|
|
I draged and droped an added registered activex control FPCapX on simple dialog in dialog based application used to display image from hardware attached.
When I start using any of its method which interact with hardware ,it gives this assert in debug mode,and in release mode it simply does not work.Control works very simply in VB applications. Actually each of this methods internally calls InvokeHelper function where the assert comes. When I searched on google about bug I found that
Activex Control is not initialised. Can anyone help on this please.
|| ART OF LIVING ||
|
|
|
|
|
|
thanks for your answer but I didnot understood where com comes into picture.
I have one COM project,though I got more theoritical knowledge than practical due to that project,I know some thing of COM.
I have added current control as per first article only.
Now my question is ,if as per your suggestion if I have to
write cointialise(NULL),where should I write.Because as per my knowledge you need to write coinitialise only for RAW COM development.
Will you please help me out.
|| ART OF LIVING ||
|
|
|
|
|
ok, obvious I dont work with ActiveX controls as much as I should, yes, I usually work with RAW COM ..
see if this thread has useful info (basically the programmer was trying to perform requests to the ActiveX object before it was initialised - in a MFC Dialog app, DoModal() inits the dialog which then inits the control)
http://p2p.wrox.com/topic.asp?TOPIC_ID=36521[^]
oh, and I went to the website for the control, and its documentation is next to useless - Id recommend you send them a note, if it was a bonafide purchase, and ask them to supply you a working example - A halfway decent supplier should always do this
'g'
|
|
|
|
|
Thank you very much for your help and efforts you took for me.
Actually in that article one is trying to set values to activex control before its dialog gets initialised. but I am trying to use capture mwthod of activex far after dialog is loaded and when user clicks button capture. One more point i want to tell you, if instead of drag and drop from control toolbar if I create control using create function of it,it doesnot give assertion but it simply does nothing.
|| ART OF LIVING ||
|
|
|
|
|
well, I take it we are talking about the same thing http://info.bioenabletech.com/Products/VB-OCX-SDK/sdk-user-guide/sdk-user-guide[^]- from http://www.bioenabletech.com/[^]
as I said, their website is pretty horrible - I cant even display their SDK help 100% ... I'd send them an email or call them and ask for a working example in c++ for MSVC6 Dialog app....
I notice their SDK says VB-OCX-SDK, but I cant imagine why an activex would only work with VB... unless there's something I dont know about how VB instantiates an activex control thats different from c++ (always possible)
Apart from it being a licensing issue (is there a .lic file ?), without much more to go on I can help much
'g'
|
|
|
|
|
yes this is same control from same company,its ftp site . I was also puzzeled by seeing term VB_OCX_SDK. How come anything be like this .
Anyway I am trying to contact the company.
We have purchased software for sixty days,thats what company which I newly joined told me. I dont know its purchased or trial version. But control works very simply with VB. There is slight difference
in VB when we add component BioFP in VB it adds to controls FPCapX and FpVerifyX. But in vc when you go in Add registered Activex Controls
you can directly see two controls FpCapx,FPVerifyX.Which after inserting gets added to control toolbar. When I tried to search ocx there is only one ocx in system32 ie BioFp. Neither FpCapX nor FpVerifyX. How come I dont know ? There is no file called FpCapx.ocx or BioFp.FpCapx.ocx .
Note In VC when this controls from toolbar are added they respectively create same classes as thier names.
|| ART OF LIVING ||
|
|
|
|
|
Hi all:
Just been wondering the difference between map and pair.
I think:
map<val1, val2=""> where val1 and val2 can be variables of deeper depth, like another map or vector or pair, but for
pair<val1, val2=""> where val1 and val2 are of simple variable types, like string or char.
Am I right?
Thank you
|
|
|
|
|