Click here to Skip to main content
15,902,112 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Program do not execute Pin
Hamid_RT22-May-07 1:28
Hamid_RT22-May-07 1:28 
Questionchild window Pin
Aint21-May-07 22:10
Aint21-May-07 22:10 
AnswerRe: child window Pin
Nelek22-May-07 0:11
protectorNelek22-May-07 0:11 
GeneralRe: child window Pin
Aint22-May-07 15:29
Aint22-May-07 15:29 
GeneralRe: child window Pin
Nelek23-May-07 21:17
protectorNelek23-May-07 21:17 
QuestionNetwork/TCP Availability Notifications Pin
Peter Weyzen21-May-07 22:02
Peter Weyzen21-May-07 22:02 
AnswerRe: Network/TCP Availability Notifications Pin
David Crow22-May-07 3:11
David Crow22-May-07 3:11 
QuestionHey Guys! I need HELP!! please! Pin
*Roxanna*21-May-07 21:43
*Roxanna*21-May-07 21:43 
How do i use the button fucntion to activate the LEDS?

The source code below is for the checkbox method:

Hope to hear from you soon!

P.s: ( Im using pin 2,4,6,and 8 of the parallel port btw to connect to the LEDs)

// ParallelPortDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ParallelPort.h"
#include "ParallelPortDlg.h"
#define DATA 0x378
#define STATUS 0x379
#define CONTROL 0x37a
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{

public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CParallelPortDlg dialog

CParallelPortDlg::CParallelPortDlg(CWnd* pParent /*=NULL*/)
: CDialog(CParallelPortDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CParallelPortDlg)
m_pin2 = FALSE;
m_pin4 = FALSE;
m_pin6 = FALSE;
m_pin8 = FALSE;

//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CParallelPortDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CParallelPortDlg)
DDX_Check(pDX, IDC_Pin2, m_pin2);
DDX_Check(pDX, IDC_Pin4, m_pin4);
DDX_Check(pDX, IDC_Pin6, m_pin6);
DDX_Check(pDX, IDC_Pin8, m_pin8);

//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CParallelPortDlg, CDialog)
//{{AFX_MSG_MAP(CParallelPortDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_TIMER()
//}}AFX_MSG_MAP
//Code added by me from here.
ON_COMMAND_RANGE(IDC_Pin2, IDC_Pin9, ChangePin)

ON_COMMAND(IDC_Pin1, ChangeControl)
//Code added by me till here

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CParallelPortDlg message handlers

BOOL CParallelPortDlg::OnInitDialog()
{

CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// 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//App.Wiz generated code
// TODO: Add extra initialization here

short _stdcall Inp32(short portaddr);
void _stdcall Out32(short portaddr, short datum);

SetTimer(1,200,NULL);
Out32(CONTROL, Inp32(CONTROL) & 0xDF);
UpdatePins();


return TRUE; // return TRUE unless you set the focus to a control
}

void CParallelPortDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}

// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void CParallelPortDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CParallelPortDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CParallelPortDlg::UpdatePins()

{

short _stdcall Inp32(short portaddr);
void _stdcall Out32(short portaddr, short datum);

int reg;
reg=Inp32(STATUS);

if((reg & 0x40)==0) m_pin10=0; else m_pin10=1;
if((reg & 0x80)==0) m_pin11=0; else m_pin11=1;
if((reg & 0x20)==0) m_pin12=0; else m_pin12=1;
if((reg & 0x10)==0) m_pin13=0; else m_pin13=1;
if((reg & 0x08)==0) m_pin15=0; else m_pin15=1;
//////////
reg=Inp32(DATA);

if((reg & 0x01)==0) m_pin2=0; else m_pin2=1;

if((reg & 0x04)==0) m_pin4=0; else m_pin4=1;

if((reg & 0x10)==0) m_pin6=0; else m_pin6=1;

if((reg & 0x40)==0) m_pin8=0; else m_pin8=1;

//////






}

void CParallelPortDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
// TODO: Add your message handler code here and/or call default


}

void CParallelPortDlg::ChangePin()
{

int data_register, new_register;
short _stdcall Inp32(short portaddr);
void _stdcall Out32(short portaddr, short datum);


UpdateData(TRUE);
data_register=Inp32( DATA );
new_register=0;
if( m_pin2==TRUE ) new_register |= 0x01;

if( m_pin4==TRUE ) new_register |= 0x04;

if( m_pin6==TRUE ) new_register |= 0x10;

if( m_pin8==TRUE ) new_register |= 0x40;


Out32(DATA, new_register);


}

void CParallelPortDlg::ChangeControl()
{


int control_register, new_register;

UpdateData(TRUE);
short _stdcall Inp32(short portaddr);
void _stdcall Out32(short portaddr, short datum);


control_register = Inp32( CONTROL );
new_register = control_register;


Out32(CONTROL, new_register);



}
QuestionRe: Hey Guys! I need HELP!! please! Pin
prasad_som21-May-07 22:56
prasad_som21-May-07 22:56 
AnswerRe: Hey Guys! I need HELP!! please! Pin
David Crow22-May-07 3:12
David Crow22-May-07 3:12 
QuestionText file Pin
ashost0721-May-07 21:35
ashost0721-May-07 21:35 
AnswerRe: Text file Pin
Christian Graus21-May-07 22:00
protectorChristian Graus21-May-07 22:00 
GeneralRe: Text file Pin
ashost0721-May-07 22:05
ashost0721-May-07 22:05 
GeneralRe: Text file Pin
Anurag Gandhi21-May-07 22:28
professionalAnurag Gandhi21-May-07 22:28 
GeneralRe: Text file Pin
Christian Graus21-May-07 22:54
protectorChristian Graus21-May-07 22:54 
AnswerRe: Text file Pin
Hamid_RT22-May-07 0:34
Hamid_RT22-May-07 0:34 
QuestionSome code of VC++ Pin
tyagineha21-May-07 21:22
tyagineha21-May-07 21:22 
AnswerRe: Some code of VC++ Pin
Christian Graus21-May-07 22:01
protectorChristian Graus21-May-07 22:01 
JokeRe: Some code of VC++ Pin
CPallini21-May-07 23:05
mveCPallini21-May-07 23:05 
GeneralRe: Some code of VC++ Pin
Mark Salsbery22-May-07 4:07
Mark Salsbery22-May-07 4:07 
AnswerRe: Some code of VC++ Pin
Mark Salsbery22-May-07 4:10
Mark Salsbery22-May-07 4:10 
QuestionCWInThread Pin
Kiran Pinjala21-May-07 21:13
Kiran Pinjala21-May-07 21:13 
AnswerRe: CWInThread Pin
Roger Stoltz21-May-07 21:31
Roger Stoltz21-May-07 21:31 
GeneralRe: CWInThread Pin
Naveen21-May-07 21:47
Naveen21-May-07 21:47 
GeneralRe: CWInThread Pin
Roger Stoltz21-May-07 22:02
Roger Stoltz21-May-07 22:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.