|
I do not know about CIMageList, but usualy when an image comes out black there it an error in the code; these can be frustrating to solve.
INTP
|
|
|
|
|
Hey,
Im working on a menu-type dialog-based program. Basically, the user can select a button and it'll run a program. The user can define what program to run by clicking Browse for each button.
What I have is a dialog box with 2 buttons, Run "CFloatDlg::OnRun()", and App1 "CFloatDlg::OnApp1()". Here is my code:
void CFloatDlg::OnApp1()
{
CFileDialog fd(TRUE,"exe",NULL,OFN_HIDEREADONLY,
"Programs (*.exe)|*.exe|All Files (*.*)|*.*||",this);
if (fd.DoModal() == IDOK)
{
m_sFilename = fd.GetPathName();
UpdateData(FALSE);
}
}
void CFloatDlg::OnRun()
{
_execlp(m_sFilename, NULL);
}
When the user clicks the App1 button, the open commondialog opens and the user can select an .exe. Then the user clicks run, and the program is executed. The program itself also closes.
How can I make the program save, (internal or external), what the user has selected so that the program selected will be there each and everytime until the user changes it? Also, how can I make it so that the dialog does not close when another program is executed from it?
P.S.: I just wanted to thank everyone for all their work and time here. I've been quiet here, but I love all the code. Everyone is doing awesome work. I do plan on providing back to the community with my own code soon. Thanks to all.
DNFSB
|
|
|
|
|
DNFSB wrote:
Also, how can I make it so that the dialog does not close when another program is executed from it?
how is OnRun called?
in OnRun are you calling baseclass OnOk()??
Your code is incomplete to discribe your problem.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
My OnRun is just:
_execlp(m_sFilename, NULL);
when the user clicks the that button, the m_sFilename selection is ran, but the dialogbox that the button is on closes as the m_sFilename is ran.
DNFSB
|
|
|
|
|
Hey,
Got another question about Menus, I have the menu and it works fine, but I created a New function, and I know in Non Dialog based options it has it done for you already, in Dialog ones, how do you have it reload the program so it is new, after clicking on the new option ni the menu.
Thanks
|
|
|
|
|
I've written a background UI COM plugin for WMP9 that does some neat stuff, but I've been hobbled somewhat by the apparent lack of a way to respond to keyboard commands. No way I've tried has worked, including creating a worker thread and calling GetAsyncKeyState. Is there something that I might be missing, or will I have to resort to keyboard hook (like "An All-Purpose Keyboard Hooker")?
|
|
|
|
|
|
That was the first thing I tried: that function is never called! To see for yourself if you want, use the wizard and make a UI/Background plugin for WMP. It's never called, possibly because it's a "background" plugin?
|
|
|
|
|
Not knowing anything about WMP9, but could you possibly hijack the window message handler for the main application window to intercept all the messages it is getting? You could respond to the ones you wanted and call the regular window handler for those you did not want?
|
|
|
|
|
I have no idea how I'd go about doing that, though; my plugin never gets a HWND.
I've actually worked around the no-hotkey problem by intuitively tying the function (don't skip this commercial) to the seekbar: if the user seeks twice inside a section containing a commercial within a few seconds, that commercial section is internally ignored.
|
|
|
|
|
Hello.
I have posted a question about this before but i wrote it bad. So i try again.
I'm working with a program that storage BMP and WAV files in one file. I'm almost finished with it but I want to make it show BMP files directly from the packed file without extracting it.
I have tried many times but I can't make function to put BITMAPINFOHEADER and BITMAPINFO correct data.
///////////////////////////////////////////////////////////////////////////////
LPTSTR szFileName = "C:\\Min Projekt\\MittPixelTest\\3_16.bmp";
CFile test;
test.Open(szFileName, CFile::modeRead);
DWORD m_nMaxSize = test.GetLength();
void *pBuf = (BYTE *) malloc(sizeof(BYTE) * m_nMaxSize);
test.ReadHuge((LPVOID) pBuf, m_nMaxSize);
LoadBMPImage(pBuf, m_nMaxSize, myBmp, &myPalette);
///////////////////////////////////////////////////////////////////////////////
BOOL CMyArchiveDlg::LoadBMPImage(void* vBits, DWORD len, CBitmap &bitmap, CPalette *pPal)
{
BITMAPFILEHEADER bmfHeader;
// Read file header
if (!memcpy((LPSTR)&bmfHeader, vBits, sizeof(bmfHeader)))
return FALSE;
// File type should be 'BM'
if (bmfHeader.bfType != ((WORD) ('M' << 8) | 'B'))
return FALSE;
// Get length of the remainder of the file and allocate memory
DWORD nPackedDIBLen = len - sizeof(BITMAPFILEHEADER);
HGLOBAL hDIB = ::GlobalAlloc(GMEM_FIXED, nPackedDIBLen);
if (hDIB == 0)
return FALSE;
// Read the remainder of the bitmap file.
if (!memcpy((LPSTR)hDIB, vBits, nPackedDIBLen))
{
::GlobalFree(hDIB);
return FALSE;
}
BITMAPINFOHEADER &bmiHeader = *(LPBITMAPINFOHEADER)hDIB ; // Gets wrong data
BITMAPINFO &bmInfo = *(LPBITMAPINFO)hDIB ;
// If bmiHeader.biClrUsed is zero we have to infer the number
// of colors from the number of bits used to specify it.
int nColors = bmiHeader.biClrUsed ? bmiHeader.biClrUsed :
1 << bmiHeader.biBitCount; // Color value is to high!!
LPVOID lpDIBBits;
if( bmInfo.bmiHeader.biBitCount > 8 )
lpDIBBits = (LPVOID)((LPDWORD)(bmInfo.bmiColors + bmInfo.bmiHeader.biClrUsed) +
((bmInfo.bmiHeader.biCompression == BI_BITFIELDS) ? 3 : 0));
else
lpDIBBits = (LPVOID)(bmInfo.bmiColors + nColors);
// Create the logical palette
if( pPal != NULL )
{
// Create the palette
if( nColors <= 256 )
{
UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * nColors);
LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];
pLP->palVersion = 0x300;
pLP->palNumEntries = nColors;
for( int i=0; i < nColors; i++)
{
pLP->palPalEntry[i].peRed = bmInfo.bmiColors[i].rgbRed;
pLP->palPalEntry[i].peGreen = bmInfo.bmiColors[i].rgbGreen;
pLP->palPalEntry[i].peBlue = bmInfo.bmiColors[i].rgbBlue;
pLP->palPalEntry[i].peFlags = 0;
}
pPal->CreatePalette( pLP );
delete[] pLP;
}
}
CClientDC dc(NULL);
CPalette* pOldPalette = NULL;
if( pPal )
{
pOldPalette = dc.SelectPalette( pPal, FALSE );
dc.RealizePalette();
}
HBITMAP hBmp = CreateDIBitmap( dc.m_hDC, // handle to device context
&bmiHeader, // pointer to bitmap size and format data
CBM_INIT, // initialization flag
lpDIBBits, // pointer to initialization data
&bmInfo, // pointer to bitmap color-format data
DIB_RGB_COLORS); // color-data usage
bitmap.Attach( hBmp ); // Here it's stops. Debug error!
if( pOldPalette )
dc.SelectPalette( pOldPalette, FALSE );
::GlobalFree(hDIB);
return TRUE;
}
I guess I use wrong type to put bitmap data but if anyone knows what's wrong with this function it would be great
|
|
|
|
|
First:
if (!memcpy((LPSTR)hDIB, vBits, nPackedDIBLen))
well normaly I would have called GlobalLock() to get the pointer, but hDIB is realy a pointer so this should work ( LPSTR should be LPVOID ).
The problem with the line is that vBits points to the start of the buffer, where the BITMAPFILEHEADER is stored and you are trying to copy the information following it:
if (!memcpy((LPSTR)hDIB, (LPBYTE)vBits + sizeof(BITMAPFILEHEADER), nPackedDIBLen))
That should fix the following:
BITMAPINFOHEADER &bmiHeader = *(LPBITMAPINFOHEADER)hDIB ; // Gets wrong data
BITMAPINFO &bmInfo = *(LPBITMAPINFO)hDIB ;
(interesting use of references!)
Try takeing a look at the CDibData article; I wrote the class so that it could take a handle to a DIB (see CDibData::Attach()) just like the clipboard.
INTP
|
|
|
|
|
Hi!
I keep getting a "User Breakpoint called from code at 0x......." I do not have any breakpoints set, but my execution seems to keep halting.
I notice if i comment out a few function function calls, my program works ok. So it seems like this error occurs when my DLL becomes a certain size.
I've never seen this before and dont know where to start trying to figure out where/how to debug it. I'm not doing anything fancy: My project is a multithreaded dll, using MFC as a shared dll. I have classes defined w/ normal inheritance and I'm including version.lib and ws2_32.lib for libraries.
I've never seen my execution simply halt. Any help would be GREATLY appreciated!! TIA.
-C
|
|
|
|
|
what about using a debugger to trace the breakpoint? it is prolly a simple assert statement.
Don't try it, just do it!
|
|
|
|
|
Apparently CFormView doesn't handle Keyboard Accelerators. that is until you have selected a form element like a textbox or list. But since I would rather have the formview recognize an accelerator without having to go in this direction is there a way I can work around this.
I have this solution, but I don't think it is working the way it should or perhaps is the wrong solution. In a nutshell I have the following code which when a document in opened and the form appears, OnInitialUpdate() is called and I call LoadAccelerators and load the handle into a variable. Later I override PreTranslateMessage() and check for this handle then call ::TranslateAccelerator() which I'm thinking takes in a window handle, thus I used my main window handle where at the accelerator keys work, the accelerator handle then the message. Here is the code.
void CFormGameOnView::OnInitialUpdate()
{
m_haccel=LoadAccelerators(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDR_FORMGAMEONVIEW_TMPL));
...
}
BOOL CFormGameOnView::PreTranslateMessage(MSG* pMsg)
{
CMainFrame *pMain = (CMainFrame*)AfxGetMainWnd();
if(m_haccel)
{
if(::TranslateAccelerator(pMain->m_hWnd, m_haccel, pMsg))
return TRUE;
}
return CFormView::PreTranslateMessage(pMsg);
}
Is this the right approach or is there a better approach?
Thanks!
|
|
|
|
|
I've never posted in this board before. This is actullay the first time i've clicked on it.
Anyways, I was reading that in C# the only way to get parallel port access in Windows XP is via a kernal mode driver. Now, I did this and it worked fine.
But, i'm messing around with C, right now and I was using the _inp and _outp functions in conio.h
So, here's my question: Can I get hardware access directly with C in windows XP? Like on 95 and 98 where I can just to _outp and it goes to whatever port I say.
/\ |_ E X E GG
|
|
|
|
|
In case of C too you need a kernel mode driver in win2k and xp
|
|
|
|
|
that's not cool. thanks for your answer.
/\ |_ E X E GG
|
|
|
|
|
|
eggie5 wrote:
Can I get hardware access directly with C in windows XP? Like on 95 and 98 where I can just to _outp and it goes to whatever port I say.
No.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
thanks for your answer.
/\ |_ E X E GG
|
|
|
|
|
This function works great when I compile a project
using Unicode Debug. Is there any similiar function
if I just use Debug mode?
|
|
|
|
|
|
I get
BindStatusCallback.obj : error LNK2001: unresolved external symbol __imp__StrFormatByteSizeA@12
Debug/Setup.exe : fatal error LNK1120: 1 unresolved externals
Its the BindStatusCallback.cpp code that you posted on
December 24, 1999: Version 1.0. Any chance you updated it since 1999?
Please let me know. My email address is brinasas@yahoo.com
The code works fine for Unicode, but in Ansi, I keep getting that
error. Drives me nuts.
I love "...give me credit where it's due. I'll know if you
don't. bwa ha ha ha ha!"
Sincerely
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Hello...
I'm currently writing a program that has to read in data from the serial port and then process it. But I thought before I tackle that part, I should write a small sample one to test to see that I can actually receive data.
I got this sample program off the MSDN website and made a couple of minor changes (original can be found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/monitoring_communications_events.asp ) to reflect the fact that it's supposed to look for any characters received.
#include [windows.h]
#include [assert.h]
#include [conio.h]
#include [iostream]
void main()
{
HANDLE hCom;
OVERLAPPED o;
BOOL fSuccess;
DWORD dwEvtMask;
hCom = CreateFile( "COM1",
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL
);
if (hCom == INVALID_HANDLE_VALUE)
{
return;
}
fSuccess = SetCommMask(hCom, EV_CTS | EV_DSR);
if (!fSuccess)
{
return;
}
o.hEvent = CreateEvent(
NULL,
FALSE,
FALSE,
NULL
);
o.Internal = 0;
o.InternalHigh = 0;
o.Offset = 0;
o.OffsetHigh = 0;
assert(o.hEvent);
if (WaitCommEvent(hCom, &dwEvtMask, &o))
{
if (dwEvtMask & EV_RXCHAR)
{
cout << "received!";
}
if (dwEvtMask & EV_CTS)
{
}
}
getch();
}
This program, when compiled, does not output "received!", even though I know there is data being sent to the serial port (COM1). Any suggestions as to why? Is there a better way to monitor for the reception of characters through the serial port? Any help is appreciated.
Thanks in advance.
|
|
|
|
|