|
If you actually mean what the season is, not just the daylight saving time flag, there isn't a single algorithm for it since different countries define the seasons differently. Ie if you try to tell someone in Australia that December 25 is in the winter, you'll get weird looks.
Also, some countries like the US define the seasons based on the solstices and equinoxes, while others change seasons on the first of the month every 3 months.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
|
|
|
|
|
shellext is a sample in sdk of MSDN.
i modify the sample but VC refuses to compile sample with my modification.
if i delete all obj files and output file from Explorere manually then re-compile it, VC doesn't re-generate any obj and output files but displays info of "no error" - actually there are some code errors because i added errors for testing.
how to re-compile it with my code?
cheers
includeh10
|
|
|
|
|
includeh10 wrote:
i modify the sample but VC refuses to compile sample with my modification.
What do you mean by "refuses?" That's a fairly vague term.
includeh10 wrote:
...VC doesn't re-generate any obj and output files...
Are you looking in the right spot for them? They may not necessarily be in the project's folder.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have two windows forms (Form1 and Form2). Form1 is the main form. I have a textbox in form2 which i need to access from form1. How can i accomplish this.
eg;
Form1 Accesses -> Form2's Text Box
Thanks in Advanced
|
|
|
|
|
hi
I suppose Both Form1 and From2 are in 2 classes..
Form1 class --->frm1
From2 Class --->frm2
When you click button in the Form1 class I have taken values of the TextBoxes in the Form2
int a,b
void frm1::OnButton1()
{
frm2 t1;
a=t1.m_textbox1;
b=t1.m_textbox2;
}
can't u do it like above?
|
|
|
|
|
I work on a cad application, in which users can plot plans on standard paper sizes but also on custom paper sizes.
To select the paper size the user can open a 'Print setup' dialogbox (a windows common dialogbox opened with
CPrintDialog::DoPrintDialog, see code), where he chooses the plotter, paper orientation & paper size.
The 'Print setup' dialogbox has a button 'Properties' that opens the properties dialogbox for the choosen plotter (this dialogbox comes
from the plotter driver). The properties dialogbox allows to define the sizes of the custom papers.
My 1st problem is that after closing the driver properties dialogbox, the 'Print setup' dialogbox does not show the new sizes
for the modified custom paper. So my application is not aware of the new sizes.
The only way i found to use the custom paper sizes is to define them outside of my application, via Start --> Parameters --> Printers.
My 2nd problem is that when one reopens a plan that had been recorded with a specific paper size (the paper ID & dimensions are saved in the plan), the printer must be reset to that paper size, even if the paper format ('custom 1' for example) was modified by another application. In others terms i need to redefine a custom paper size by programmation.
The driver is HP Designjet 750C, version 4.65. I'm using win XP.
The code : i got a lot of it from samples in msdn or others forums; i have poor understanding of it, it's seems to me like an awful garbage, but at least it works as long the user uses standard paper formats (ansi A0, ...). Sorry to insert so much code but there several functions specific to printer handling and i think i have to show it all.
void CDlgPlan::OnPrinterSetup() <br />
{<br />
CPrintDialog dlg(TRUE);<br />
if (AfxGetApp()->DoPrintDialog(&dlg) == IDOK)<br />
{<br />
LPDEVMODE pDevMode = dlg.GetDevMode();<br />
m_strPrinterName = dlg.GetDeviceName();<br />
SetParamPrinter((const char *)m_strPrinterName, pDevMode->dmOrientation, <br />
pDevMode->dmPaperSize, pDevMode->dmPaperLength, pDevMode->dmPaperWidth);<br />
GetPrinterInfo();<br />
::GlobalUnlock(pDevMode);<br />
}<br />
}<br />
<br />
BOOL CDlgPlan::SetParamPrinter(const char *pPrinterName, short dmOrientation, short IDPapier, short paperLength, short paperWidth)<br />
{<br />
BOOL res;<br />
PRINTER_INFO_2 *pPrinterInfo;<br />
DEVMODE *pDevModeTmp;<br />
HANDLE hPrinter;<br />
res = GetParamPrinter(pPrinterName, &pPrinterInfo, hPrinter, &pDevModeTmp);<br />
if (! res)<br />
goto cleanup;<br />
pPrinterInfo->pDevMode->dmFields = DM_ORIENTATION|DM_PAPERSIZE|DM_PAPERLENGTH|DM_PAPERWIDTH;<br />
pPrinterInfo->pDevMode->dmOrientation = dmOrientation;<br />
pPrinterInfo->pDevMode->dmPaperSize = IDPapier;<br />
pPrinterInfo->pDevMode->dmPaperLength = paperLength;<br />
pPrinterInfo->pDevMode->dmPaperWidth = paperWidth;<br />
pPrinterInfo->pSecurityDescriptor = NULL;<br />
<br />
res = ( DocumentProperties(NULL, hPrinter, (char *)pPrinterName, pPrinterInfo->pDevMode, <br />
pPrinterInfo->pDevMode, DM_IN_BUFFER|DM_OUT_BUFFER) == IDOK );<br />
if (! res)<br />
goto cleanup;<br />
<br />
res = SetPrinter(hPrinter, 2, (LPBYTE)pPrinterInfo, 0);<br />
if (! res)
goto cleanup;<br />
<br />
cleanup:<br />
if (pDevModeTmp)<br />
GlobalFree(pDevModeTmp);<br />
if (pPrinterInfo)<br />
GlobalFree(pPrinterInfo);<br />
if (hPrinter)<br />
ClosePrinter(hPrinter);<br />
return res;<br />
} <br />
<br />
void CDlgPlan::GetPrinterInfo()<br />
{<br />
PRINTER_INFO_2 *pPrinterInfo;<br />
DEVMODE *pDevModeTmp;<br />
HANDLE hPrinter;<br />
CDC DC;<br />
<br />
if (! GetParamPrinter(m_pVplan->m_strPrinterName, &pPrinterInfo, hPrinter, &pDevModeTmp) )<br />
goto cleanup;<br />
<br />
DC.CreateDC(pPrinterInfo->pDriverName, pPrinterInfo->pPrinterName, pPrinterInfo->pPortName, pPrinterInfo->pDevMode);<br />
m_lLongPapier = DC.GetDeviceCaps(HORZSIZE); <br />
m_lHautPapier = DC.GetDeviceCaps(VERTSIZE) ;<br />
m_pVplan->m_f.paperLength = m_lLongPapier * 10;
m_pVplan->m_f.paperWidth = m_lHautPapier * 10;<br />
DC.DeleteDC();<br />
m_pVplan->m_f.IDFormat = pPrinterInfo->pDevMode->dmPaperSize;<br />
m_pVplan->m_f.Bits.bPaysage = (pPrinterInfo->pDevMode->dmOrientation == DMORIENT_LANDSCAPE);<br />
m_pVplan->m_f.Bits.typePaper = m_typePaper;<br />
<br />
cleanup:<br />
if (pDevModeTmp)<br />
GlobalFree(pDevModeTmp);<br />
if (pPrinterInfo)<br />
GlobalFree(pPrinterInfo);<br />
if (hPrinter)<br />
ClosePrinter(hPrinter);<br />
} <br />
<br />
BOOL CDlgPlan::GetParamPrinter(const char *pPrinterName, PRINTER_INFO_2 **ppPrinterInfo, HANDLE &hPrinter, DEVMODE **ppDevModeTmp)<br />
{<br />
DWORD dwSizePrinterInfo = 0;<br />
PRINTER_DEFAULTS pd;<br />
BOOL bFlag;<br />
LONG lFlag;<br />
<br />
hPrinter = NULL;<br />
*ppPrinterInfo = NULL;<br />
*ppDevModeTmp = NULL;<br />
<br />
ZeroMemory(&pd, sizeof(pd));<br />
pd.DesiredAccess = PRINTER_ALL_ACCESS;
if (! OpenPrinter((char *)pPrinterName, &hPrinter, &pd) || hPrinter == NULL)<br />
return FALSE;<br />
SetLastError(0);<br />
bFlag = GetPrinter(hPrinter, 2, 0, 0, &dwSizePrinterInfo);<br />
if ( ! bFlag && (GetLastError() != ERROR_INSUFFICIENT_BUFFER) || (dwSizePrinterInfo == 0))<br />
return FALSE;<br />
<br />
*ppPrinterInfo = (PRINTER_INFO_2 *)GlobalAlloc(GPTR, dwSizePrinterInfo);<br />
if (*ppPrinterInfo == NULL)<br />
return FALSE;<br />
if (! GetPrinter(hPrinter, 2, (LPBYTE)*ppPrinterInfo, dwSizePrinterInfo, &dwSizePrinterInfo) )<br />
return FALSE;<br />
<br />
if ((*ppPrinterInfo)->pDevMode == NULL)<br />
{<br />
long dwNeeded = DocumentProperties(NULL, hPrinter, (char *)pPrinterName,NULL, NULL, 0);<br />
if (dwNeeded <= 0)<br />
return FALSE;<br />
*ppDevModeTmp = (DEVMODE *)GlobalAlloc(GPTR, dwNeeded);<br />
if (*ppDevModeTmp == NULL)<br />
return FALSE;<br />
lFlag = DocumentProperties(NULL, hPrinter, (char *)pPrinterName, *ppDevModeTmp, NULL, DM_OUT_BUFFER);<br />
if (lFlag != IDOK || *ppDevModeTmp == NULL)<br />
return FALSE;<br />
(*ppPrinterInfo)->pDevMode = *ppDevModeTmp;<br />
}<br />
return TRUE;<br />
}<br />
<br />
BOOL CDlgPlan::GetPrinterDevice(const char * pszPrinterName, HGLOBAL* phDevNames, HGLOBAL* phDevMode)<br />
{<br />
if (phDevMode == NULL || phDevNames == NULL)<br />
return FALSE;<br />
<br />
BOOL res;<br />
PRINTER_INFO_2 *pPrinterInfo;<br />
DEVMODE *pDevModeTmp;<br />
HANDLE hPrinter;<br />
long tcOffset, size, drvNameLen, ptrNameLen, porNameLen;<br />
HGLOBAL hDevMode, hDevNames;<br />
DEVNAMES* pDevNames;<br />
DEVMODE* pDevMode;<br />
<br />
res = GetParamPrinter(pszPrinterName, &pPrinterInfo, hPrinter, &pDevModeTmp);<br />
if (! res)<br />
goto cleanup;<br />
<br />
size = sizeof(*pPrinterInfo->pDevMode) + pPrinterInfo->pDevMode->dmDriverExtra;<br />
hDevMode = GlobalAlloc(GHND, size);<br />
ASSERT(hDevMode);<br />
pDevMode = (DEVMODE*)GlobalLock(hDevMode);<br />
ASSERT(pDevMode);<br />
<br />
memcpy(pDevMode, pPrinterInfo->pDevMode, size);<br />
GlobalUnlock(hDevMode);<br />
<br />
drvNameLen = lstrlen(pPrinterInfo->pDriverName) + 1;
ptrNameLen = lstrlen(pPrinterInfo->pPrinterName) + 1;
porNameLen = lstrlen(pPrinterInfo->pPortName) + 1;
<br />
hDevNames = GlobalAlloc(GHND, sizeof(DEVNAMES) + (drvNameLen + ptrNameLen + porNameLen)*sizeof(TCHAR));<br />
ASSERT(hDevNames);<br />
pDevNames = (DEVNAMES*)GlobalLock(hDevNames);<br />
ASSERT(pDevNames);<br />
<br />
tcOffset = sizeof(DEVNAMES)/sizeof(TCHAR);<br />
ASSERT(sizeof(DEVNAMES) == tcOffset*sizeof(TCHAR));<br />
<br />
pDevNames->wDriverOffset = (int)tcOffset;<br />
memcpy((LPTSTR)pDevNames + tcOffset, pPrinterInfo->pDriverName, drvNameLen*sizeof(TCHAR));<br />
tcOffset += drvNameLen;<br />
<br />
pDevNames->wDeviceOffset = (int)tcOffset;<br />
memcpy((LPTSTR)pDevNames + tcOffset, pPrinterInfo->pPrinterName, ptrNameLen*sizeof(TCHAR));<br />
tcOffset += ptrNameLen;<br />
<br />
pDevNames->wOutputOffset = (int)tcOffset;<br />
memcpy((LPTSTR)pDevNames + tcOffset, pPrinterInfo->pPortName, porNameLen*sizeof(TCHAR));<br />
pDevNames->wDefault = 0;<br />
<br />
GlobalUnlock(hDevNames);<br />
<br />
*phDevMode = hDevMode;<br />
*phDevNames = hDevNames;<br />
<br />
cleanup:<br />
if (pDevModeTmp)<br />
GlobalFree(pDevModeTmp);<br />
if (pPrinterInfo)<br />
GlobalFree(pPrinterInfo);<br />
if (hPrinter)<br />
ClosePrinter(hPrinter);<br />
<br />
return res;<br />
} <br />
<br />
<br />
HGLOBAL hDevMode = NULL;<br />
HGLOBAL hDevNames = NULL;<br />
GetPrinterDevice(m_strPrinterName, &hDevNames, &hDevMode);<br />
AfxGetApp()->SelectPrinter(hDevNames, hDevMode);<br />
SetParamPrinter(m_strPrinterName, (short)m_pVplan->m_f.Bits.bPaysage ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT, (short)m_pVplan->m_f.IDFormat, (short)m_pVplan->m_f.paperLength, (short)m_pVplan->m_f.paperWidth);
|
|
|
|
|
Hi All,
Seasons Greetings!!
Im Mirza Faizan, currently a trainee at ELECTRONICS AND RADAR DEVELOPMENT ESTABLISHMENT, DRDO, Bangalore. In my academic project, I have to develop a Device driver Hardware Acceptance Test for a communication card for Control and Display Unit of a RADAR. I have seen your project on www.codeproject.com, and immediatelt realized that you can be my help!! plz plz plz...
My problem is that I am developing GUI for the driver in VC++. And I am having trouble with the following thing:
1) I have to develop a GUI in which POST is done for 24V, 5V, 3.3V, 2.5V.
*If the check is successful, then the button should become GREEN and the caption on the button should be 'OK'.
*If the check is failed, then the button should become RED and the caption on the button should be 'FAILED'. And when the user click on button, a dialog box should appear telling him what to do next.
2) Please also do tell me how to declare variable (not attached with the controls, but extra variable where I should store values of voltages which are checked.
3) Please tell me how to add C,C++ code in the GUI developed in VC++. I mean, Im developing GUI in VC++ and writing device driver in C, C++
Please help me with this. I'll be highly obliged with this kind act of yours.
Regards
Mirza Faizan
Trainee
Electronics and Radar Development Establishment.
DRDO, Bangalore
Phone:08051305747
Email:mirzafaizan@gmail.com
|
|
|
|
|
Hi All,
I have created many application on VC++ 4my company for there Networking department that allows me to view a remote desktop on my LAN using Socket client and server application (WinSock 1.1) . Here what i do is i install the server on the remote machine then i captures the desktop using SDK fn(),s and then passes it byte by byte using send() and recv() fn's.
I even hide my server application from task manager so that it is not visible and i make it start up thru registery so the admin has installed it on all the computers. they passes the ip adderss and justs connect it using client application
Now My Question is
Can there be some way on LAN where i can access remote desk top without installing the server program???
Could the Answer be accessing some Remote Procedural Call (RPC's)
Which topic or fn,s do i need to study??
I read that there r softwares which allows the Admin on LAN to moniter a computer without installing the server program.. They r some stand alone programs
Which topic or fn,s do i need to study??
Thnx in advance
Comboy2080
|
|
|
|
|
How can i tile a jpeg to the background of a dialog.
thnx
Tariq
|
|
|
|
|
you shd look for some image library that give you handle or display the jpg.
-->if you looking in COM/ATL
-->look for interface IPicture
---->if you looking in RAW MFC/API
--->look for CxImage In CP,best Graphics Library present in Town
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
hello,
im looking for retreiving a pointer to a function from its name stored in a string...
thx for help.
|
|
|
|
|
hi
well so for i got ur question the function name is itself a pointer to the address space of ur program
Suppose i want to make a pointer to a ftn that return UINT and take UINT as single argument
then prototype will be like this
UINT (*p2ftn)(UINT);
p2ftn=function;
p2ftn(23);
|
|
|
|
|
i allrdy know that. and thats not what i want to do.
ex:
void myFuncNameString (void)
{
foobar();
}
void main (void)
{
char* var = "myFuncNameString";
// Here I want to call myFuncNameString only knowing the string....
|
|
|
|
|
The only way I know of, is to get the pointer to a function exported in a dll.
The C/C++ compiler takes the name of your function and translates it to an adress, no meta information is preserved when the application is compiled.
That's why we got file specifications like dll and elf, they describe a format that allows for exporting function tables.
If it's a feature you really need, then you could use a Hashtable to store pointers to your functions mapped by their name.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
hmmm...
u mean using some code like this:
typedef DWORD (*FCT_PTR)( bool pText);
struct MyStruct
{
char * name;
FCT_PTR funct;
};
const MyStruct funcHashT[] =
{
{ "foo", foo },
{ "bar", bar },
}
void foo (bool pText) { //blehbleh }
void bar (bool pText) { //blehbleh }
...
I think its ok for pure c functions, but my prob is that i need to make a new object only knowing his name (or his constructor name). same problem as above except that foo and bar are classes...
|
|
|
|
|
|
Template are out from my current knowledge but ill take a look at them asap.
But, do u think can do the following using the post i paste before:
new funcHashT[i].funct (true);
????
|
|
|
|
|
fickdb wrote:
I think its ok for pure c functions, but my prob is that i need to make a new object only knowing his name (or his constructor name). same problem as above except that foo and bar are classes...
The word you're looking for, I suppose, is Reflection. This is not possible in C++ for the same reasons as I mentioned before.
But you can of course work around the limitations, to do so requires a solid knowledge of the language and tools.
If you know, and understand, COM, you will realize that the interface IDispatch is invented for just that reason. Again, if you really need the feature, you could either use COM and IDispatch, or you could copy the technique.
What it all comes down to though, is that you're probably better of using C# for your project.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
I find a workaround:
typedef void (*FCT_PTR)( bool pText);
struct MyStruct
{
char * name;
FCT_PTR funct;
};
void wrapper_foo (bool pText) { new foo(pText); }
const MyStruct funcHashT[] =
{
{ "foo", wrapper_foo }
}
class foo
{
public:
foo(bool pBool)
{
// Code
}
}
I tested this code in a very simple c++ project and it works fine.
|
|
|
|
|
This solution should work. Nice idea 
|
|
|
|
|
Hi,
How to create a GUI based application for example dialog based which will except the paramters. Actually our .exe will be called from VB application and 5 paramters are passed to that application.
Thanks in Advance.
Azghar
|
|
|
|
|
In dialog Based application in the CYourApp::InitInstance
call the function GetCommandLine and then parse the parameters
Regards
vikrant_kpr
|
|
|
|
|
hi,
I want to do Insert ,delete actions in a SQL Server Database using C++/MFC.
Can any body please tell me how to do that or give me the URLs?
thanks in advance..
|
|
|
|
|
Try reading about CRecordset, if you want to use MFC, along with CDatabase.
Alternatively, you can use ATL helper classes and use OLEDB, in which case CDataSource, CSession and CCommand/CAccessor stuff is what you want.
Steve S
Developer for hire
|
|
|
|
|
I have a old project, written by BC++4.5. Now I want to convert it to VC++, How can I do??
Thanks!
|
|
|
|
|