|
Blaine,
Thank you for taking the time to answer this simple question. When I tried to implement your suggestion I got this ...
4030R TestingDlg.cpp
C:\CCViews\ggerber_view\cmd_proc\4030R Hemi Test\4030R TestingDlg.cpp(123) : error C2664: 'void __thiscall CWnd::GetDlgItem(int,struct HWND__ ** ) const' : cannot convert parameter 1 from 'struct HWND__ *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\CCViews\ggerber_view\cmd_proc\4030R Hemi Test\4030R TestingDlg.cpp(124) : error C2065: 'wParam' : undeclared identifier
Error executing cl.exe.
Here is my OnInitDialog Function Code ...
BOOL C4030RDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, true); // Set big icon
SetIcon(m_hIcon, false); // Set small icon
// TODO: Add extra initialization here
hDlgWnd = GetSafeHwnd();
THREADINFO* ptp = new THREADINFO;
ptp->hWnd = hDlgWnd;
g_pThread = AfxBeginThread(ThreadPanelRead, ptp, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
// Creates a 12-point-Courier-font
m_Font.CreatePointFont(120, _T("Arial Bold"));
// Set Font without a member variable
GetDlgItem(IDC_EDIT_L5)->SetFont(&m_Font);
GetDlgItem(IDC_EDIT_L4)->SetFont(&m_Font);
GetDlgItem(IDC_EDIT_L3)->SetFont(&m_Font);
GetDlgItem(IDC_EDIT_L2)->SetFont(&m_Font);
GetDlgItem(IDC_EDIT_L1)->SetFont(&m_Font);
GetDlgItem(IDC_EDIT_R5)->SetFont(&m_Font);
GetDlgItem(IDC_EDIT_R4)->SetFont(&m_Font);
GetDlgItem(IDC_EDIT_R3)->SetFont(&m_Font);
GetDlgItem(IDC_EDIT_R2)->SetFont(&m_Font);
GetDlgItem(IDC_EDIT_R1)->SetFont(&m_Font);
GetDlgItem(IDC_STATUS)->SetFont(&m_Font);
GetDlgItem(IDC_TRIG_MODE)->SetFont(&m_Font);
HWND hWndControl = GetDlgItem(this->m_hWnd, IDC_CHECK1);
SendMessage(hWndControl, IDC_CHECK1, BM_SETCHECK, wParam, BST_CHECKED, 0);
g_bContAquire = false;
g_nTriggerSource = UNKNOWN_TRIGGER;
return true; // return true unless you set the focus to a control
}
I hope this helps and again thanks for helping out a newbie ...
Greg
|
|
|
|
|
I forgot that GetDlgItem is also a member function of CDialog.
Same goes for SendMessage.
Okay, so give it global scope - notice two semi-colon in front of function names.
Sorry
HWND hWndControl = ::GetDlgItem(this->m_hWnd, IDC_CHECK1);<br />
::SendMessage(hWndControl, IDC_CHECK1, BM_SETCHECK, BST_CHECKED, 0);
See also other responses, which might be preferable in your situation, since most of the rest of your code is MFC.
Also, the m_hWnd of a dialog is valid during the OnInitDialog, certainly after the base class has been called, so you can probably reduce to this:
THREADINFO* ptp = new THREADINFO;<br />
ptp->hWnd = m_hWnd;<br />
g_pThread = AfxBeginThread(ThreadPanelRead, ptp, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
|
|
|
|
|
m_myCheckBox.SetCheck (BST_CHECKED);
CheckDlgButton (IDC_MY_CHECKBOX, BST_CHECKED); /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks for all your time and help ...
Greg
|
|
|
|
|
Simple, there's two ways to do it:
- The first way is to use the GetDlgItem(control's ID)
cast it to a pointer to a type CButton as viz:
<br />
CButton *pCheck = reinterpret_cast<CButton *>(GetDlgItem(IDC_CHECK1));<br />
pCheck->SetCheck(TRUE);<br />
of:
- Using Class Wizard (or maunally), map the check box to a "Control" category variable of type CButton (default)
bot in your dialog's header file
<br />
enum { IDD = IDD_CHECK_DIALOG };<br />
CButton m_check;<br />
and in the DoDataExchange method
<br />
<br />
void CCheckDlg::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CDialog::DoDataExchange(pDX);<br />
DDX_Control(pDX, IDC_CHECK1, m_check);<br />
}<br />
have been added (or you have to insert DDX_Control(pDX, IDC_CHECK1, m_check); if done manuallY)
the code in OnInitDialog is such:
<br />
m_check.SetCheck(TRUE);<br />
Happy programming,
Alton
|
|
|
|
|
Thanks for all your time and help ...
Greg
|
|
|
|
|
Alton Williams wrote:
m_check.SetCheck(TRUE);
Even though TRUE and BST_CHECKED resolve to the same value, this method of using SetCheck() is not recommended.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
I want to make a playlist editor for my MP3 player. I've upped the playlist file to my server. You can download it here:
www.tommy2d.com/MyFavorite.plp
I can open it with notepad without any problems. However, when i save it to UNICODE LE, UNICODEBE or whatever format Notepad support, i can't load aymore on my MP3 player...
Could anybody please indicate what type of file this is and how to open it in C++?
Thnx...
|
|
|
|
|
I know that format from Samsung players. The player expects the file to be little-endian UTF-16 with no byte order mark. When you save the file with Notepad, it adds the BOM, so you'll need to remove it before putting the file on the player.
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Ok, thanks for this information ...But how do i go writing a program that is capable of reading and writing such files? At the moment, I'm using the CTextFileRead class found on this site. But this class is not capable of reading UTF16 files I believe...
|
|
|
|
|
|
Hi,
I just the following code but it just reads the first char and then it quits on my poor textfile. This is the same thing as what happened when i used the class. The size it determines is correct however.
Please help me on this. I don't have any exp with anything else then just plain char arrays I really don't know what to do next.
<br />
#include <iostream><br />
#include <fstream><br />
#include <stdlib.h><br />
#include <windows.h><br />
using namespace std;<br />
<br />
const char * filename = "J:\\MyJukeBox\\PLAYLIST\\MyFavorite.plp";<br />
<br />
int main () {<br />
wchar_t * buffer;<br />
long size;<br />
wfstream file (filename, ios::in|ios::ate);<br />
size = file.tellg();<br />
file.seekg (0, ios::beg);<br />
buffer = new wchar_t [size];<br />
file.read (buffer, size);<br />
file.close();<br />
<br />
cout << "the complete file is in a buffer. Size:" << size;<br />
MessageBox(0,buffer,NULL,0);<br />
<br />
delete[] buffer;<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|
Is the problem with reading the file or displaying it in your messagebox?
The first thing I would suggest is to use debugger to check if
file.read (buffer, size);
actually reads the file into buffer (break after this line and look at buffer.)
If buffer does not contain the correct contents, the problem is with reading. Maybe the read is expecting 8-bit ASCI?
If buffer actually has the ciorrect contents, the problem may be that
MessageBox(0,buffer,NULL,0);
expects buffer to be ASCI text, so if it is contains a 0x00 byte, this is seen as end of string.
|
|
|
|
|
The problem is with the reading, but i already knew that. I just really don't know how to read this file...The format was UTF16 without the last byte...
|
|
|
|
|
Hi,
I want to make a playlist editor for my MP3 player. I've upped the playlist file to my server. You can download it here:
www.tommy2k.com/MyFavorite.plp
I can open it with notepad without any problems. However, when i save it to UNICODE LE, UNICODEBE or whatever format Notepad support, i can't load aymore on my MP3 player...
Could anybody please indicate what type of file this is and how to open it in C++?
Thnx...
|
|
|
|
|
Dear all,
I have a program which, when active, sits in the taskbar. So long as the progam is open I want to add a button next to the min/max/close buttons on all open windows (operating system windows xp). Does anyone know where I can find example code where this is being done... I have searched through the code project website but haven't been able to locate anything of this nature and would be really grateful if someone could give me some help.
Thanks
Andrew
|
|
|
|
|
Hi, I need to delete a file.
When i do :
if( remove( tpath ) == -1 ) perror( "Could not delete file" );
else printf( "Deleted\n" );
I get : access denied, I know this is because the file is still open but for personal reasons I can't close it, I just need to delete it
So this file really needs to be destroyed, is there a way to force the deletion ??
|
|
|
|
|
Are you not in a position where the file could be closed first, then deleted?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
|
hi - i have an mfc activex control and want to save its visuals to a file. how should i do this? the graphics on the control are created through GDI+, so should i go through Graphics contents to an Image, or may be through CDC? thanx
so far i have this:
CDC* pdc = GetDC();
RECT rect;
GetClientRect(&rect);
Graphics graphics(pdc->GetSafeHdc());
Bitmap bitmap(rect.right -
rect.left, rect.bottom -
rect.top, &graphics);
CLSID pngClsid;
GetEncoderClsid(L"image/jpeg", &pngClsid);
bitmap.Save(fineName, &pngClsid, NULL);
but it just outputs a black screen, which is understandable
|
|
|
|
|
You should be able to use the WM_PRINT message to render the control into a DC of your own choice.
With a bitmap of your own sleected into it of the correct size, you could then save the output to a file.
If you vote me down, my score will only get lower
|
|
|
|
|
thanx, Roger, i didn't notice anybody replied to the post. i found a solution, check my previous post.
i guess your idea is close to what i finally implemented - thanx !
|
|
|
|
|
my search led me to GdipCreateBitmapFromGraphics method and this post:
http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=37541&lngWId=1
where this guy - "Avery" - gives a great hint
|
|
|
|
|
Is it possible to clear the internet history and if so how?
|
|
|
|