|
I've had this problem too - try putting in a wait for a few seconds after the open, and see what happens.
|
|
|
|
|
Hello.
I'm writing a forms processing app, using MFC, which reads form data
from an XML file. By form data I mean - what the form is supposed to look like, coordinates
of where each form element is located, type of form element (button, textfield, table, etc.)
So far I had no problems creating controls on a CDialog - I just used CreateWindow with preset classnames (COMBOBOX, EDIT, etc). However there are two elements I'm not quite sure how to display:
One is a Table, for which I thought I'd use MSFlexGrid and another - DataControl, for which I was going to use the Microsoft ADO Data Control.
The thing is I cannot find any docs on how to display those without making use of dialog templates.
Could anyone help me out?
Thank you.
Marat Garafutdinov.
|
|
|
|
|
MSHFlexGrid has a create function:
virtual BOOL Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL)
Try using this function, and I think that the Class Name is not that important because I don't see it being used in the function's body.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
I am having problem with accessing a particular location of bitmap.
what i want to do is store the x,y coordinates of black pixels on a perfectly white background. The error code is "GetPixel' : cannot convert parameter 1 from 'struct HDIB__ ** ' to 'struct HDC__ *'"
I tried GetPixel (x,y) but it doent work neither.
Does anyone know?Thanks!
POINT* p=new POINT[length];
POINT* p2=new POINT[length];
int w=cxDIB;//the width of the image
int h=cyDIB;//the height of the bitmap
i=0;
for(w=0;w<=cxDIB;w++)
{
for(h=0;h<=cyDIB;h++)
{
p[i].x=w;
p[i].y=h;
i++;
}}
i=0;
for(w=0;w<=cxDIB;w++)
{
for(h=0;h<=cyDIB;h++)
{
if(GetPixel(m_hDIB2,p->x,p->y)==RGB(0,0,0)) p2[i] =p[i];
i++;
}}
delete [] p;
delete [] buf;
|
|
|
|
|
A DIB is not a device context the following code will hopefully start you on your way. It does not handle all DIB formats especially it does not handle RLL compressed DIBs. You need to consider the DIBInfo which will specify page vs interleaved pixels, number of color planes and bits per pixel. Also each scanline will be padded to 4 byte ie DWORD boundaries.
As you can see it was written a long time ago in Win32 but i doubt the basic structures have changed.
Depending on your requirements it might be easier to render the DIB into a CMemDC and retrieve the pixels from there ?
/*************************************************************************
*
* getDIBPixel(hDIB, x , y)
*
* Parameter:
*
* HDIB hDIB - handle to global memory with a DIB spec
* in it followed by the DIB bits
*
* Return Value:
*
* DWORD - index to color of pixel or RGB for 24 bit or
* RGBX for 32 bit per pixel bitmaps
*
* Description:
*
* This function finds the color of a DIB pixel
*
************************************************************************/
DWORD WINAPI getDIBPixel(HDIB hDIB, int x, int y)
{
DWORD dwColor;
WORD wBitCount;
DWORD dwWidth, dwHeight, dwX, dwY;
DWORD scanline_bytes;
LPSTR lpDIB; // pointer to packed-DIB
LPSTR lpDIBBits; // Pointer to DIB bits
LPBITMAPINFO lpbmi; // pointer to BITMAPINFO structure (Win3.0)
LPBITMAPCOREINFO lpbmc; // pointer to BITMAPCOREINFO structure (old)
lpDIB = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);
lpDIBBits = ::FindDIBBits(lpDIB);
// get pointer to BITMAPINFO (Win 3.0)
lpbmi = (LPBITMAPINFO)lpDIB;
// get pointer to BITMAPCOREINFO (old 1.x)
lpbmc = (LPBITMAPCOREINFO)lpDIB;
// the number of bits per pixel for the DIB
if (IS_WIN30_DIB(lpDIB))
wBitCount = ((LPBITMAPINFOHEADER)lpDIB)->biBitCount;
else
wBitCount = ((LPBITMAPCOREHEADER)lpDIB)->bcBitCount;
// end of number of bits per pixel
dwWidth = ::DIBWidth(lpDIB);
dwHeight = ::DIBHeight(lpDIB);
dwX = (DWORD) x;
dwY = dwHeight - (DWORD) (y + 1);
// TRACE2("getDIBPixel dwX=%ld, dwY=%ld\n", dwX, dwY);
// WIDTHBYTES performs DWORD-aligning of DIB scanlines. The "bits"
// parameter is the bit count for the scanline (biWidth * biBitCount),
// and this macro returns the number of DWORD-aligned bytes needed
// to hold those bits.
scanline_bytes = (((dwWidth * (DWORD) wBitCount) + 31) / 32 * 4);
DWORD dwXoffset, dwYoffset, dwXBitoffset;
DWORD pixel_addr;
BYTE pixel_data;
dwXoffset = ((dwX * (DWORD) wBitCount) / 8);
dwXBitoffset = (dwX * (DWORD) wBitCount) - (dwXoffset * 8);
dwYoffset = (dwY * scanline_bytes);
// TRACE3("getDIBPixel dwXoffset=%ld dwXBitoffset=%ld dwYoffset=%ld\n",dwXoffset, dwXBitoffset, dwYoffset);
pixel_addr = dwYoffset;
pixel_addr += dwXoffset;
pixel_data = *( (BYTE huge *)lpDIBBits + pixel_addr );
// TRACE1("getDIBPixel pixel_data=0x%x\n", pixel_data);
//extract relevant bits
switch (wBitCount) {
case 1:
break;
case 2:
break;
case 4:
switch(dwXBitoffset) {
case 0:
pixel_data = pixel_data>>4;
pixel_data = pixel_data & 0x0F;
break;
case 4:
pixel_data = pixel_data & 0x0F;
break;
}
dwColor = (DWORD) pixel_data;
break;
case 8:
dwColor = (DWORD) pixel_data;
break;
case 24:
// TRACE1("Blue = 0x%x",pixel_data);
dwColor = (DWORD) pixel_data;
pixel_data = *( (BYTE huge *)lpDIBBits + pixel_addr + 1 );
// TRACE1("Green = 0x%x",pixel_data);
dwColor += (DWORD) pixel_data * 256;
pixel_data = *( (BYTE huge *)lpDIBBits + pixel_addr + 2);
// TRACE1("Red = 0x%x\n",pixel_data);
dwColor += (DWORD) pixel_data * 65536;
break;
}
::GlobalUnlock((HGLOBAL) hDIB);
// TRACE1("getDIBPixel dwColor=0x%lx\n", dwColor);
return(dwColor);
}
|
|
|
|
|
Thank you ever so much , I will try and inform you of the outcome
|
|
|
|
|
Hi,
Am trying to find an implemenation of the
Zero Proof Algorithm in C++.
Does anyone have any pointers, have found it
in C# but not in C++, does it exist?
many thanks
|
|
|
|
|
If i create a raw socket, build my own IP and UDP header, and then use sendto() to send a packet.. what does the buffer have to contain? just data.. or the entire packet data with the header data and everything?
Kuniva
--------------------------------------------
|
|
|
|
|
|
But how does the socket know the source address it should use? I mean, the idea of the raw socket is that we can use setsockopt() to tell it it should use OUR header, and not the one filled in by windows by default. But in sendto() it would only get the socket,the data and a sockaddr_in structure as parameters, so you are saying the data for the header should be somewhere in the socket handle... because the sockaddr_in structure only contains data for the destination. I don't see how this is possible since a SOCKET is just a handle, an int.. How does it know the header to use? Perhaps you have an example for sending a packet with your own header? It would clarify a lot for me...
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
Microsoft have an example of using SOCK_RAW here
|
|
|
|
|
Hey,
I'm thinking about creating a little "game" that will produce a little character on your monitor, the character will walk around and do random little things, and interact with the cursor, and (hopefully) other windows. I'd like to make this character appear to be IN the computer, not an application or game. I'd like all other windows to be seen, and icons to be clickable, etc. For example:
I load up my game, and then decide to open winamp. Without having to minimize anything, or move any windows, I can just double click the winamp icon on my desktop. My character (still visible the whole time) keeps walking around or dancing, or whatever he wants to do the whole time.
I hope I've explained myself well enough.
Thanks in advance!
-Brian
-untwisted
www.uber-ware.com
brian@uber-ware.com
|
|
|
|
|
|
If I create a web service in C#, is it possible to consume it in normal C++ ? Is it going to be a nightmare ? I'm trying to decide on a home project and thinking of an app to use sourcesafe remotely, web service one end, C++ app the other ( so that the .NET framework is not needed remotely ).
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Christian Graus wrote:
If I create a web service in C#, is it possible to consume it in normal C++ ?
If by "normal C++" you mean VC 7.x, then yes. You need to use ATL Server like in this example.
Christian Graus wrote:
Is it going to be a nightmare ?
For development, no. For deployment - it requires MSXML which is a drag.
|
|
|
|
|
Cool - thank you. MSXML is a lot smaller than the .NET framework, and included in IE 5.5 ( from memory ), so that's still a lot easier in terms of deployment IMO. So that suits me just great.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Not sure if this the answer you're looking for, but if the web service accepts HTTP GET requests, like CP's service, then you can call IXMLDOMDocument::load() and pass it the URL to the service, and let the XML parser do the rest. Check out my CP screen saver, which uses this method.
BTW MSXML comes with IE 5+, and is available as a redistributable for those poor people stuck on IE 4.
--Mike--
Latest blog entry: *drool* (Alyson) [May 10]
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
This example seems to write both server and client in ATL, is it possible to write the server in C#, or does that complicate things ?
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Christian Graus wrote:
is it possible to write the server in C#, or does that complicate things ?
Yes. In fact you can write the server in any programming language, as long as you have a valid SOAP library.
However, I've tried only the opposite combination: ATL server and C# client. It worked just fine, and I assume (but cannot guarantee) that your case will be fine too.
|
|
|
|
|
The web service will return an xml which you can "consume" in normal c++.
Jason Henderson My articles
"The best argument against democracy is a five-minute conversation with the average voter." - Winston Churchill
|
|
|
|
|
which function can capture mouse and cursor events of system?
is it possible to capture their shapes (i.e. Arrow or user icon of mouse, cursor shape in different edit)?
thx
includeh10
|
|
|
|
|
It sounds like you are needing a system-wide hook. See if SetWindowsHookEx() works.
|
|
|
|
|
Forgive me if I am using the wrong terminology.
By system tool bar I mean the bar that defaults to the top of each application. The bar that host the minimize, maximize and close buttons.
Two questions.
(1) what is this area of the screen correctly called? Is it the frame?
(2) Can you point me towards an article that would show me how to add a button to this bar?
thanks
|
|
|
|
|
McGahanFL wrote:
Can you point me towards an article that would show me how to add a button to this bar?
There actually is one here on CodeProject about that!
I don't remember where because it was like hell to find it when I was searching for it!
Happy searching! (if not somebody post the link)
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Hi,
I have a DlgApp that launch other applications. When the user click on a button, a popup menu is created with some data that I have collected in my database. The user then need to select an item into the menu. The selected info is used as parameters to launch the other app.
This is my click button handler:
void CmyDlg::OnBnClickedBtnDbmanager()
{
CMenu myMenu;
CRect rect;
m_wndDBBtn.GetWindowRect(&rect);
monMenu.CreatePopupMenu();
monMenu.AppendMenu(MF_STRING, 0, "Name1");
monMenu.AppendMenu(MF_STRING, 0, "Name2");
monMenu.AppendMenu(MF_STRING, 0, "Name3");
monMenu.AppendMenu(MF_STRING, 0, "Name4");
myMenu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON, rect.left+20, rect.top+20, AfxGetMainWnd());
}
I would like to know how I can get the index of the menu. For example, if I select name4 into the menu, I would like something to tell me that the fourth item is selected... After that, I can use GetMenuString() to retrieve my data and launch my other App.
As you can see, unstead of ID as second parameter into AppendMenu() I have 0. The reason of this is that I dont know how many info I will have to put into my menu, so i can't provide ID for each of them.
Any Ideas?
Everything's beautiful if you look at it long enough...
|
|
|
|
|