|
Mal-Functi wrote: But how can I search for a point that is not a single integer? How can I compare if it's higher or lower to go to next node?
have you tried:
if X1 > X2 then
if Y1 > Y2 then
P1 is > P2
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Hello,
You can try the following:
std::pair<int, int> PointPair(x,y);
if( PointPair > PPn )
{ }
Hope this helps
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
what about MAKELONG MACRO
DWORD dwEncodeVal=MAKELONG(x,y);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
int the function OnDraw();I want to create a DIB bitmap using the array pData,and display it on the screen,but I am not fail to do it;Would please tell me how to correct the codes below.
//the array containing color information
unsigned char* pData=new unsigned char[768*576*3];
int y=0, x=0;
for(;y<576;y++)
for(;x<768;x++)
{
pData[x*3+y*768*3]=0;
pData[x*3+1+y*768*3]=0;
pData[x*3+2+y*768*3]=255;
}
//information header
BITMAPINFOHEADER FrameBmi;
FrameBmi.biSize=sizeof(BITMAPINFOHEADER);
FrameBmi.biPlanes=1;
FrameBmi.biCompression=BI_RGB;
FrameBmi.biClrImportant=0;
FrameBmi.biSizeImage=768*576*3;
FrameBmi.biClrUsed=0;
FrameBmi.biBitCount=24;
FrameBmi.biWidth=768;
FrameBmi.biHeight=576;
FrameBmi.biXPelsPerMeter = 0;
FrameBmi.biYPelsPerMeter =0;
//file header
BITMAPFILEHEADER pf;
pf.bfType=0x4d42; //"BM"
pf.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(char[768*576]);
pf.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
pf.bfReserved1=0;
pf.bfReserved2=0;
//BITMAPINFOHEADER
LPBITMAPINFO lpbmi=(LPBITMAPINFO)GlobalAlloc(GMEM_FIXED,sizeof(BITMAPINFOHEADER));
ASSERT(lpbmi);
lpbmi->bmiHeader.biSize=FrameBmi.biSize;
lpbmi->bmiHeader.biPlanes=FrameBmi.biPlanes;
lpbmi->bmiHeader.biCompression=FrameBmi.biCompression;
lpbmi->bmiHeader.biClrImportant=FrameBmi.biClrImportant;
lpbmi->bmiHeader.biSizeImage=FrameBmi.biSizeImage;
lpbmi->bmiHeader.biClrUsed=FrameBmi.biClrUsed;
lpbmi->bmiHeader.biBitCount=FrameBmi.biBitCount;
lpbmi->bmiHeader.biWidth=FrameBmi.biWidth;
lpbmi->bmiHeader.biHeight=FrameBmi.biHeight;
lpbmi->bmiHeader.biXPelsPerMeter=FrameBmi.biXPelsPerMeter;
lpbmi->bmiHeader.biYPelsPerMeter=FrameBmi.biYPelsPerMeter;
lpbmi->bmiColors=NULL;
//Create DIBitmap
CBitmap *OldBitmap;
HBITMAP bmp =::CreateDIBitmap((HDC)pDC,&FrameBmi,CBM_INIT,pData,lpbmi, DIB_RGB_COLORS);
ASSERT(bmp);
//
CBitmap bitmap;
bitmap.Attach(bmp);
CDC dcComp;
dcComp.CreateCompatibleDC(pDC);
OldBitmap=dcComp.SelectObject(&bitmap);
BITMAP bm;
bitmap.GetObject(sizeof(BITMAP),&bm);
// draw bitmap
pDC->BitBlt(0,0,768,576,&dcComp,0,0,SRCCOPY);
dcComp.SelectObject(OldBitmap);
delete [] pData;
GlobalFree(lpbmi);
delteDC(dcComp);
I LOVE VC
-- modified at 6:43 Sunday 16th October, 2005
|
|
|
|
|
|
I got a error that there was a ASSERT error in the line of "CreateDIBitmap()",
I am fail to create a DIB bitmap and display it in the monitor.
I LOVE VC
|
|
|
|
|
|
pData is too small for the bitmap you are trying to create.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
yes,the pData should be pData=new unsigned char[768*576*3],but after above update,I am fail to create the DIB bitmap again,
I LOVE VC
|
|
|
|
|
::CreateBitmap(pDC->m_hDC, ...
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
My code:
<br />
#include "stdafx.h"<br />
#include <windows.h><br />
<br />
<br />
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow);<br />
<br />
void main()<br />
{<br />
MessageBox(NULL , "Question 1", "Do you like World Of Warcraft?", NULL | MB_YESNOCANCEL);<br />
<br />
}<br />
How can you make it so if he clicks yes it prints "Good Choice" and if he clicks no it will open a ".com" file?
Any resposes will be very helpful.
Another passing being longing to enhance his intellect.
Gnaritas est potestas.
Knowledge is power.
|
|
|
|
|
int nResponse = MessageBox(NULL , "Question 1", "Do you like World Of Warcraft?", MB_YESNOCANCEL);
if (IDYES == nResponse)
MessageBox(NULL, "Response", "Good Choice", MB_OK);
else if (IDNO == nResponse)
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
MessageBox returns a value which indicates whether the user choose yes or no.
<br />
int nResult = MessageBox(...);<br />
<br />
if (nResult == IDYES)<br />
...<br />
<br />
else if (nResult == IDNO)<br />
...<br />
<br />
"When you know you're going to eat crow, it's best to eat it while it's still warm." - Reader's Digest
|
|
|
|
|
Thanks mate, I really appreciate it
Another passing being longing to enhance his intellect.
Gnaritas est potestas.
Knowledge is power.
|
|
|
|
|
if(IDOK==MessageBox(NULL , "Question 1", "Do you like World Of Warcraft?", NULL | MB_YESNOCANCEL))
then
{
add you code here
}
else
{
add you code here
}
I LOVE VC
|
|
|
|
|
Hi,
I want to delete a class from my project
(class view) butI am not sure that how to do it.
I looked through all file, edit menu.
I don't see any options to do so.
I tried to delete the cpp & h files but
I got compilation error, C1083:
Cannot open source file:.........
Can someone give me some suggestions?
Thanks,
Kevin
|
|
|
|
|
you should also delete the cpp&h files in the "FILEVIEW" of workspace view(which containing three view,Class view,resource views,fileview),delete the cpp file in the "Soure Files",and delete the h file int the "Header files".Following above steps, you will not get the compilatin error.
I LOVE VC
-- modified at 21:58 Saturday 15th October, 2005
|
|
|
|
|
|
I need to be able to list webcams that are plugged in. I can use DeviceChange to tell when a webcam is plugged or unplugged and I am then using the function shown below to create a list of all video devices. This works for all "normal" webcam devices since they appear and disappear from the list when I call the function after they are plugged in or unplugged. Unfortunately, I also have an older webcam, Logitech "Quickcam", that is ALWAYS listed regardless of whether it is plugged in or not... That represents a pathological case. I need a way to determine if it is really plugged in WITHOUT disrupting it in case my software is currently using it. I have scoured all 5 device driver and USB books I know of, scoured MSDN, scoured the internet, tried LOTS of code including USBView which ALMOST provides the information but DISPLAYS A DIFFERENT NAME (not the "FriendlyName" I expected!) so I cannot correlate the information. Anyone know of a solution? (I think this is a REALLY tough problem... I will be unavailable for a couple of weeks but I really need to find a solution and will respond as soon as possible...)
VideoDeviceList *CMotionDetectDlg::GetVideoDeviceList()
{
static VideoDeviceList VideoList;
USES_CONVERSION;
UINT uIndex = 0;
HRESULT hr;
BOOL bCheck = FALSE;
//Clear all previous video list entries
for(int i = 0; i < NUMELMS(VideoList.videoMoniker); i++)
{
if(VideoList.videoMoniker[i]){
VideoList.videoMoniker[i]->Release();
VideoList.videoMoniker[i] = NULL;
}
}
VideoList.videoString.RemoveAll();
VideoList.numberOfDevices = 0;
// enumerate all video capture devices
ICreateDevEnum *pCreateDevEnum = 0;
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (void**)&pCreateDevEnum);
if(hr != NOERROR)
{
MessageBox(NULL, "Error Creating Device Enumerator");
return NULL;
}
IEnumMoniker *pEm = 0;
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
&pEm, 0);
if(hr != NOERROR)
{
CString message;
message = CString("No Video capture device was found.\r\n\r\n")
+ CString("Please plug in a webcam or other video capture device.");
//MessageBox(message, "Notice");
if(pEm)pEm->Release();
return NULL;
}
pEm->Reset();
ULONG cFetched;
IMoniker *pM;
while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK)
{
IPropertyBag *pBag=0;
hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
if(SUCCEEDED(hr))
{
//VARIANT vardes;
//vardes.vt = VT_BSTR;
//hr = pBag->Read(L"Description", &vardes, NULL);
VARIANT var;
var.vt = VT_BSTR;
hr = pBag->Read(L"FriendlyName", &var, NULL);
if(hr == NOERROR)
{
VideoList.videoString.InsertAt(uIndex, CString(W2T(var.bstrVal)));
SysFreeString(var.bstrVal);
VideoList.numberOfDevices++;
ASSERT(VideoList.videoMoniker[uIndex] == 0);
VideoList.videoMoniker[uIndex] = pM;
pM->AddRef();
}
pBag->Release();
}
pM->Release();
uIndex++;
}
pEm->Release();
return &VideoList;
}
THANKS!
Howard C. Anderson
HTTP://www.astroshow.com
HTTP://www.azcendant.com
|
|
|
|
|
If you try to BindToObject() after verifying the success of BindToStorage()
wouldn't that succeed of fail depending on the presence of the device?
(I could be wrong but I don't think it will disrupt the device if it is
in use) [edit] I can confirm after testing, this does not distrupt a
running device. I can't confirm that BindToObject will fail if the device
is not plugged in; I don't have a device that enumerates if not plugged
in.[/edit]
e.g. ...
<font color=#fbedb5>__</font>hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
<font color=#fbedb5>__</font>if(SUCCEEDED(hr))
<font color=#fbedb5>__</font>{
<font color=#fbedb5>____</font>IBaseFilter *pDevice;
<font color=#fbedb5>____</font>hr = pM->BindToObject(0, 0, IID_IBaseFilter, (void**)&pDevice);
<font color=#fbedb5>____</font>if(SUCCEEDED(hr))
<font color=#fbedb5>____</font>{
<font color=#fbedb5>______</font>pDevice->Release();
<font color=#fbedb5>______</font>...
<font color=#fbedb5>______</font>...
Steve T
-- modified at 13:53 Thursday 20th October, 2005
|
|
|
|
|
Hi,
Finally I have returned... Sorry for delayed response.
I know if I use AddFilter to add to the capture graph, I can tell whether the device is there. However, I think that means I have to disrupt it, i.e., eliminate it from the capture graph and then reconnect it. That would interrupt the video.
I tried your suggestion but it answers S_OK even when the camera is not attached! Like I said, this is a pathological case caused by the method used by this older QuickCam.
It is set up so that you have to use "Unplug or Eject Hardware" to make the driver go away. Newer systems handle this automatically. Wonder if I can figure out what the "Unplug or Eject Hardware" function is doing? If I could, then maybe I could use that to determine the status.
I will continue looking at functions that might be used to determine status. Your idea gave me some other ideas to try...
Thanks,
Howard
Howard C. Anderson
HTTP://www.astroshow.com
|
|
|
|
|
Hi,
I am new to MFC. I am trying to invoke a dialog from
the menu.
I read the menus for beginners.
http://www.codeproject.com/menu/MenusForBeginners.asp
But I still a bit confused.
Here is what I did.
I already created a dialog, ID: IDD_MY_DIALOG.
I also created a menu item and added event_handler
with Message type: COMMAND, Class list: CMainFrame,
ID: ID_MY_DIALOG.
So, the Wizard created a default method for me
void CMainFrame::OnMy_Dialog()
{
// TODO: Add your command handler code here
}
But I don't how to invoke my dialog when
user clicked the "My_Dialog" menu item.
Any help would be appreciated?
Thanks,
Kevin
|
|
|
|
|
When you created the dialog, you will have been prompted to create a wrapper class for it, e.g. CMyNewDialog.
To pop one of these dialogs up you would do:
CMyNewDialog dlgBox; // object is not a window until you call DoModal etc
dlgBox.DoModal();
This would show the dialog on the screen
If you vote me down, my score will only get lower
|
|
|
|
|
Hi Roger,
> When you created the dialog, you will have been prompted to
> create a wrapper class for it, e.g. CMyNewDialog.
When I right-mouse-clicked, it just pops up a default dialog.
It did not prompted me to create a wrapper class.
Can you tell me how to do so?
>To pop one of these dialogs up you would do:
>CMyNewDialog dlgBox; // object is not a window until you call DoModal etc
>dlgBox.DoModal();
Oh yeah! I remember I read this from some books before.
Really appreciated your help.
Thanks,
Kevin
|
|
|
|
|
I think I found the answer.
1) Open up the resource view.
2) click the dialog ID.
3) right click the dialog to add class.
|
|
|
|
|