|
You can't! use CListCtrl. CListBox has less features than CListCtrl but
a CListCtrl is a bit harder to use.
|
|
|
|
|
Thank you for all!
Sonork ID 100.10002:Yaumen
|
|
|
|
|
Hi -
VC6 NT4 and Win98
I'm having a problem where TrackPopupMenu() fails and ERR is 0. I make the call inside a worker thread. Why does it fail there with no error? I read somewhere that TrackPopupMenu has its own message pump. Is this true?
Here's some code:
//
// this method works.
// TrackPopupMenu returns 1 and the menu is displayed.
//
void CTestMenusDlg::OnButton1()
{
CMenu *pMenu = new CMenu();
VERIFY(pMenu->CreatePopupMenu());
VERIFY(pMenu->AppendMenu(MF_STRING | MF_ENABLED, 32001, "Test1"));
VERIFY(pMenu->AppendMenu(MF_STRING | MF_ENABLED, 32002, "Test2"));
BOOL bOK = ::TrackPopupMenu(pMenu->m_hMenu,
TPM_LEFTALIGN |TPM_RIGHTBUTTON,
300, 300, 0, this->m_hWnd, NULL);
}
//
// this method will start a thread
//
void CTestMenusDlg::OnButton2()
{
CWinThread *pThread = AfxBeginThread(
PipeThread, this, 0,THREAD_PRIORITY_NORMAL,0,NULL);
}
//
// Runs same code as button1.
// TrackPopupMenu returns 0 and ERR is 0
//
UINT PipeThread(LPVOID lpvParams)
{
ASSERT( NULL != lpvParams );
CTestMenusDlg *pDlg = reinterpret_cast<CTestMenusDlg *>( lpvParams );
CMenu *pMenu = new CMenu();
VERIFY(pMenu->CreatePopupMenu());
VERIFY(pMenu->AppendMenu(MF_STRING | MF_ENABLED, 32001, "Test1"));
VERIFY(pMenu->AppendMenu(MF_STRING | MF_ENABLED, 32002, "Test2"));
BOOL bOK = ::TrackPopupMenu(pMenu->m_hMenu,
TPM_LEFTALIGN | TPM_RIGHTBUTTON,
300, 300, 0, pDlg->m_hWnd, NULL);
DWORD dwErr = ::GetLastError();
return 0;
}
|
|
|
|
|
I have a question:
Why you want to create a popup menu from a worker thread?
|
|
|
|
|
>> Why you want to create a popup menu from a worker thread?
Actually my real code does the opposite of my example. A worker thread gets sent a menu hierarchy via CORBA, creates a bunch of HMENUs and stores them in a table. Later on, when an item in a view is right-clicked, I look up the appropriate HMENU and create a popup.
When I started to debug this thing, I was sure that it was a threading issue and I thought that I couldn't share HMENUs across threads. I wrote a TestMenu app to check this theory out and I somehow flipped it so that the popups were being created inside the worker thread.
I've solved my problem though - a coding error in the worker thread was creating empty menus. Good HMENUs, but just no items. Still, in this instance and in my example code, when TrackPopupMenu was failing, it returns 0 and GetLastError is 0.
If TrackPopupMenu has its own message pump (as someone wrote in another post) and I pass a valid hWnd to TrackPopupMenu, why would it matter though if I called it from a non-UI (worker) thread?
thanks
|
|
|
|
|
Hi All,
We are having a requirement in which we need to calculate sunrise and sunset time depending on latitude, longitude and time zone. It would be of great help if you could suggest us any alogrithm to calculate the sunrise and sunset times.
Thanks
Prashanth
|
|
|
|
|
|
Hello!!
I will develope the multithread Syslog Server !!
But, I am novice for MFC!!
Can you say the sample code for UDP server using AsyncSocket?
Thanks in advanced!!
Bye..
|
|
|
|
|
How could I find out which NIC a NT4.0 workstation is using?
The program will be ran on the workstation.
|
|
|
|
|
If you're only interested in the IP addresses, check Warren Young's Winsock Programmer's FAQ example Getting the Local IP Address. If you're looking for more comprehensive information about the NICs, then SNMP is the way to go, and you might find it interesting having a look at Lee Hamel's article Retrieving NIC information using SNMP queries.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have one vc++ application.In that i have taken exe and i made a cab file.One .ocx control is present this ocx calls the exe file.I placed the cab file in net,so whenever a user clicks one link then the cab file is calling.So that my exe file is executing.Actually my ocx component is having the virisign registration.So,my component is providing some security to the user sytem.For security purpose it is showing one dialog box that is showing this message.
"Warning:The authority of this content can't be verified,therefore it can't be trusted.
Problem Listed below
The test root has not been enabled as a trusted root.Do you want to install and run the "abc" signed on 2001-12-11,....etc."
My Doubt:Even though i have registered ocx component,but it is showing this type of dialog box like the authority of this content can't be verified.
So,is it problem of creation of cab file.So,how can i solve my problem.So that i can supply trusted software to all endusers.
Can anybody help me in this case.
it is a company which deals with AI and different
types of web based applications
|
|
|
|
|
In my MFC application I had to create a static callback member function. The function works ok, but now I need to declare a static data member.
So I added a static member like so…
class Blah
{
public:
static HRESULT SomeCallback (…);
static int YayIAmStatic;
.
.
.
}
This compiles ok, but when I try to access the static member (from within the static callback or any other regular method) I get the following linker error:
unresolved external symbol "public: static int Blah::YayIAmStatic"
Is this not the appropriate syntax for creating a static member? Please humour a poor newbie – this is my first crack at an MFC program.
|
|
|
|
|
To declare a static variable in class Blah, put the statement in the header, as you have, then in the .cpp file put
int Blah::YayIAmStatic;
As it stands, you've told the compiler there is going to be a static int, but you've not created it.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I am doing a project related to video/image processing in Win32 environment.
Now, I would do something like printing a bitmap file. The input parameter I get would be "standard bitmap format" data (ex: a buffer like BYTE*). So, how can I do with this buffer (ex: BYTE* ) and print the bitmap format to printer ?
Any response would be greatly appreciated !
|
|
|
|
|
A printer has a DC, you simply StretchBlt it from a DC containing your bitmap to the printer. You will *always* stretch it, because otherwise the image will be smaller than a postage stamp. Don't forget to set the COLORONCOLOR StretchBlt mode.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Christian, can you explain your answer a little bit more, cos I have had this problem on my app. I managed to fix it by stretchblt'ing it with an offset, however this only worked for my PC. I recently tested it on someone else's PC and it was like a postage stamp despite my offset. Again, ur input would be much appreciated,
Alan.
P.S. did u fix that problem you had with the min/max track size of the child window (where it wouldn`t resize below a 100?) cos I posted a reply, but I think u must've solved it by that time.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
You actually need to find out the size of the print DC for the specific printer you are working with. Also, some HP printers do not report this correctly if you're using DirectX, we spoke to HP about this and they said they know about the problem, but they will only fix it *in our app* ( they admit the problem is their drivers ) if we give them all our source code and a pile of money.
I do it like this:
CPrintDialog dlg(false);
dlg.GetDefaults();
HDC hdc = dlg.GetPrinterDC();
ASSERT(hdc);
CDC DC;
DC.Attach(hdc);
m_PrintAreaHorz = GetDeviceCaps(hdc, HORZRES);
m_PrintAreaVert = GetDeviceCaps(hdc, VERTRES);
DC.DeleteDC();
which gives me the width and height I need to stretch to in order to fill the page. This should work for any printer, that is, if you stretch to these co-ordinates ( you'll obviously not want to, for aspect ratio reasons as much as anything ), you will fill the printable area of the page on any size/DPI printer.
Chambers wrote:
P.S. did u fix that problem you had with the min/max track size of the child window (where it wouldn`t resize below a 100?) cos I posted a reply, but I think u must've solved it by that time.
No, I've left it for now. For some reasons the MinMax is right, but Windows is not letting me size down to a width of 50, it stops at 100. I think the problem is in our Python code, somewhere.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Thanks Christian, I`ve managed to get it going now, just hope it works on other PC's, wish me luck,
Many Thanks,
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
Good luck
Printing is a royal pain at times, but the way I showed you is the right way to get the dimensions for every page. I did three implimentations of printing in different apps before I felt I was doing it *well*. I'm not especially keen on how MFC puts it all together, either.
"Only a master of evil, Darth"Obi Wan Kenobi
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
CPrintDialog dlg(false);
dlg.GetDefaults();
HDC hdc = dlg.GetPrinterDC();
ASSERT(hdc);
CDC DC;
DC.Attach(hdc);
m_PrintAreaHorz = GetDeviceCaps(hdc, HORZRES);
m_PrintAreaVert = GetDeviceCaps(hdc, VERTRES);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DC.DeleteDC();
Christian,
Thanks for your reply.
But I got another question as quoted as "^^^^^" above.
Does this print to the "original size" of this bitmap file ? (i.e, original width and height of this bitmap)
|
|
|
|
|
Well, it's given you the width and height of the print DC, it's got nothing to do with the bitmap. You'll need to know the physical size of the paper ( A3, A4, Legal) in order to turn that into something physical and then you need to use these values with respect to aspect ratio correction as well.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
And, another question...
If, what I get is just a buffer like RGB-24 data ? How to print it ?
Do I need to convert or save it as a standard BMP format ?
How to do that ? (i.e, save RGB-24 data to BMP format ?) What kind of header do I need to add ? Or how can I get the dimension (i.e, width and height) from this RGB-24 data ?
Any reply would be greatly appreciated..
|
|
|
|
|
You cna pass the buffer into a CBitmap constructor, although I'm not sure if a printer DC will print any bit depth DDB. I'd play it safe and create a DIBSection, then you can just memset the buffer into it.
If you call CreateDIBSection, you get a pointer to the data and you can copy your buffer into it.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
If I use StretchBlt, can I print "color" image ? (I mean, if my printer is color...)
Another API I found is: DrawDibDraw, can I also use this API to print "color" image ?
|
|
|
|
|
manio wrote:
f I use StretchBlt, can I print "color" image ? (I mean, if my printer is color...)
OF course, that is what COLORONCOLOR is for, to smooth the colours when stretching.
manio wrote:
Another API I found is: DrawDibDraw, can I also use this API to print "color" image ?
Must be - no point having a 2 color DIB. I believe this API is part of VFW, I know Chris' DIBSection wrapper uses it and I believe it does dithering. But I've never used it so I can't comment beyond that.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|