|
No N should never be the same, that's the main propose :\
My hope is that we can do it only with 'some math'!
|
|
|
|
|
Do you want to generate a unique value called N?
-prakash
|
|
|
|
|
No, any X and Y should give a unique N
(X=2,Y=2) should return always the same N
(X=1,Y=3) should always return any other N
N can be any integer
|
|
|
|
|
But there are much more (X,Y) pairs than Ns, so every pair can't have unique N.
|
|
|
|
|
Problem is:
1. I have to, in some way, save points (x,y) to a skiplist
2. I've to search for that point in that skiplist and return true if is in it otherwise false.
3. 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?
|
|
|
|
|
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
|
|
|
|
|