|
While rendering the display for a edit control if I use variable width fonts like MS Sans Serif ???
Does this mean i'd have to calculate the position of the caret each keypress rather than just calculate the width once say during OnSetFont() while using a fixed width font like Courier New ...?
Thats seems a little over kill, but I guess nessecary if I want to support variable width fonts also...?
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
hi experts
i like to display the printer properties information in controls of my dialog box. how can i fetch that values. if i use DocumentProperties with DM_IN_PROMPT attribute it displays the corresponding properties window of the printer. Instead of displaying that i want to read that setting and place values in my own dialog controls. I mean what kind of papersizes it supports, page orientation and etc.how can i acheive this please help me
from
venu
|
|
|
|
|
In order to know whether a dial-up client is still
connected to the server, i use gethostbyaddr() passed with client's IP
(which is dynamic)in the server program to
check (this is for the case that the client closes(or
drops accidentally) the dial-up connection without
closing the socket connection in advance; if client closes
the socket connection, the server is able to know that).
But i get error with code 11004, which i believe is
something about dababase. My question is: can i use
gethostbyaddr() in the server program to check client's
abnormal disconnetion? if so, what's wrong with my method?
if not, what would be the proper way?
Thanks a lot!
Wenrich
|
|
|
|
|
Wenrich wrote:
My question is: can i use
gethostbyaddr() in the server program to check client's
abnormal disconnetion?
no. check if the socket is still connected
|
|
|
|
|
In the Unix world, you'd use select() . In windows you can use the same API, select()[^] or WSAAsyncSelect()[^].
Using plain old select() , you'd test your exceptfds' with the FD_ISSET() macro to check if an exception occured with a socket.
Alternatively, you could just send() or recv() from the socket and check the return value of WSAGetLastError() for what you need.
NOTE: The Microsoft Berkley Socket implementation send() and recv() block, the WSA equivalents provide several alternatives which allow sending a message to a window when socket events occur (probably a better bet for you, if you aren't too deep with Unix-style sockets.)
-- ian
"The greatest danger to humanity is humanity without an open mind." - Ian Mariano
http://www.ian-space.com/
|
|
|
|
|
I have for the last few hours hacked endlessly at the CEdit control...i'v subclassed the control in question and tried overriding it's message handling switch code with my own and I still can't quite get it do do things that I want without serious overhaul...
Syntax hilighting, line numbers and such...
Anyways my quesiton is this...I need a editor to work on relativley small files...all web based langs like PHP,ASP,HTML,XML,JScript all of which I always try and make smaller than 64K in size (including comments) I find it's hard for me to keep organized when files grow larger than this anyways...
Sorry I went off topic there a bit...
My question: ( I already am familiar with the classes available on CP )
Because I wanna make the assumption no more memory than 64K
or I guess 65535(FFFF) bytes will ever be needed would it be acceptable for me to do the following for memory allocation...? Sure it wastes memory sometimes, but I don't think it'll get fragmented because it's prolly all allocated in one linear array of bytes...
char m_arrBytes[0xFFFF];
I would prefer to use this instead of new/delete or malloc and similar c functions...
No need to ever worry about leaks...no fragmentation...
I'm just wondering if I maybe missed something...other than extensibility...remember i'm very confident that FFFF bytes is enough for all web based project files. Besides it would force good programming practice (IMO) keeping your files small
Opinions...???
despite the fact i'm prety dead set on using this approach...perhaps you can change my mind if you bring something to my attention I didn't already know..
Then I would really appreciate your help...
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
what are you more specific questions?
|
|
|
|
|
Anonymous wrote:
what are you more specific questions?
None...thats it...I wasn't looking for answers just opinions...if you know something I don't or that maybe I missed...I would just like to hear it...
Like maybe:
char m_arrBytes[0xFFFF];
can get fragmented under certain circumstances...I dunno although I seriously 100% dought it
This is all I wanted to know
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Now I can write data from program to text file by using WriteString() and SeekToEnd().
So I want to write program to copy all data within first text file to second text file by using CStdioFile
Do you know how to do that?
Thank you for your answer.
These below is some part of my program to write data from program to text file by using CStioFile
outp_filename = m_uniquecodeFileName;<br />
<br />
CStdioFile EncryptedUniqueCode;<br />
CFileException FileExc;<br />
UINT nOpenFlags;<br />
CString szTemp, m_string;<br />
nOpenFlags = CFile::modeWrite;<br />
if (!EncryptedUniqueCode.Open(outp_filename, nOpenFlags, &FileExc)) {<br />
FileExc.ReportError();<br />
return;<br />
}<br />
EncryptedUniqueCode.SeekToEnd();<br />
<br />
.<br />
.<br />
.<br />
<br />
EncryptedUniqueCode.WriteString(m_string+'\n');<br />
<br />
EncryptedUniqueCode.Close();
|
|
|
|
|
Is there a reason you need to use CStioFile ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Is there the other way to do that? Christian.
If you know how to do that, please tell me.
|
|
|
|
|
If you open one file with an ifstream and the other with an ofstream, you can use getline to read the file a line at a time and then copy it into the new file. Something like:
#include <iostream>;
#include <string>;
...
std::ifstream input("c:\input.txt");
std::ofstream output("c:\input.txt");
std::string s;
while (std::getline(input, s))
{
output << s << std::endl;
}
But that is off the top of my head with no error checking, etc.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
This is more efficient (no parsing needed):
ifstream ifs("in.txt");
ofstream ofs("out.txt");
ofs<<ifs.rdbuf();
Anyway, I think there's no compelling reason not to use ::CopyFile instead.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi.
I have a formview with a tab control. Basically, I would like the formview to show different objects depending on which tab the user activates. I have considered using a lot of if/else and enable/disable the objects, but CTabCtrl is a more elegant solution. Thus I am designing the program around CTabCtrl.
There are three formview classes and one tab control.
ViewMain
theTab
ViewChild1
ViewChild2
I added theTab in formview ViewMain. There is not problem there. However, now I cannot figure out how to correspond ViewChild1 and ViewChild2 to the theTab.
I would like to know, Is it valid to create the two childviews from CFormView? If yes, given the design described above, How do you correspond the two childviews to the CTabCtrl object?
Thanks,
Kuphryn
|
|
|
|
|
kuphryn wrote:
I cannot figure out how to correspond ViewChild1 and ViewChild2 to the theTab.
What Exactly u meant by this...
kuphryn wrote:
Is it valid to create the two childviews from CFormView
Yeah it is Valid
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
Given three formview classes and one with a CTabCtrl object, I want to show either childview1 or childview2 depending on what tab the user clicks.
Kuphryn
|
|
|
|
|
my vb program is as follows
this works fine.
Option Explicit
#If Win32 Then
Private Declare Function SQLAllocEnv Lib "odbc32.dll" _
(phenv As Long) As Integer
Private Declare Function SQLAllocConnect Lib "odbc32.dll" _
(ByVal henv As Long, phdbc As Long) As Integer
Private Declare Function SQLConnect Lib "odbc32.dll" ( _
ByVal hdbc As Long, ByVal szDSN As String, _
ByVal cbDSN As Integer, ByVal szUID As String, _
ByVal cbUID As Integer, ByVal szAuthStr As String, _
ByVal cbAuthStr As Integer) As Integer
Private Declare Function SQLFreeEnv Lib "odbc32.dll" _
(ByVal henv As Long) As Integer
Private Declare Function SQLFreeConnect Lib "odbc32.dll" _
(ByVal hdbc As Long) As Integer
Private Declare Function SQLError Lib "odbc32.dll" ( _
ByVal henv As Long, ByVal hdbc As Long, ByVal hstmt As Long, _
ByVal szSqlState As String, pfNativeError As Long, _
ByVal szErrorMsg As String, ByVal cbErrorMsgMax As Integer, _
pcbErrorMsg As Integer) As Integer
#ElseIf Win16 Then
Private Declare Function SQLAllocEnv Lib "odbc.dll" _
(phenv As Long) As Integer
Private Declare Function SQLAllocConnect Lib "odbc.dll" _
(ByVal henv As Long, phdbc As Long) As Integer
Private Declare Function SQLConnect Lib "odbc.dll" ( _
ByVal hdbc As Long, ByVal szDSN As String, _
ByVal cbDSN As Integer, ByVal szUID As String, _
ByVal cbUID As Integer, ByVal szAuthStr As String, _
ByVal cbAuthStr As Integer) As Integer
Private Declare Function SQLFreeEnv Lib "odbc.dll" _
(ByVal henv As Long) As Integer
Private Declare Function SQLFreeConnect Lib "odbc.dll" _
(ByVal hdbc As Long) As Integer
Private Declare Function SQLError Lib "odbc.dll" ( _
ByVal henv As Long, ByVal hdbc As Long, _
ByVal hstmt As Long, ByVal szSqlState As String, _
pfNativeError As Long, ByVal szErrorMsg As String, _
ByVal cbErrorMsgMax As Integer, pcbErrorMsg As Integer) _
As Integer
#End If
Private Const SQL_SUCCESS As Long = 0
Private Const SQL_SUCCESS_WITH_INFO As Long = 1
Private Function IsValidODBCLogin(ByVal sDSN As String, _
ByVal sUID As String, ByVal sPWD As String) As Boolean
Dim henv As Long 'Environment Handle
Dim hdbc As Long 'Connection Handle
Dim iResult As Integer
'Obtain Environment Handle
iResult = SQLAllocEnv(henv)
If iResult <> SQL_SUCCESS Then
IsValidODBCLogin = False
Exit Function
End If
'Obtain Connection Handle
iResult = SQLAllocConnect(henv, hdbc)
If iResult <> SQL_SUCCESS Then
IsValidODBCLogin = False
iResult = SQLFreeEnv(henv)
Exit Function
End If
'Test Connect Parameters
iResult = SQLConnect(hdbc, sDSN, Len(sDSN), sUID, Len(sUID), _
sPWD, Len(sPWD))
If iResult <> SQL_SUCCESS Then
If iResult = SQL_SUCCESS_WITH_INFO Then
'The Connection has been successful, but SQLState Information
'has been returned
'Obtain all the SQLState Information
If Check1.Value Then ShowSQLErrorInfo hdbc, vbInformation
IsValidODBCLogin = True
Else
'Obtain all the Error Information
If Check1.Value Then ShowSQLErrorInfo hdbc, vbExclamation
IsValidODBCLogin = False
End If
Else
IsValidODBCLogin = True
End If
'Free Connection Handle and Environment Handle
iResult = SQLFreeConnect(hdbc)
iResult = SQLFreeEnv(henv)
End Function
Private Sub Form_Load()
Text1.Text = "DSN"
Text2.Text = "User ID"
Text3.Text = ""
Text3.PasswordChar = "*"
Command1.Caption = "Test Connect"
Check1.Caption = "Return Errors and Warnings"
End Sub
Private Sub Command1_Click()
Dim sServer As String, sLogin As String, sPassword As String
sServer = Text1.Text
sLogin = Text2.Text
sPassword = Text3.Text
If IsValidODBCLogin(sServer, sLogin, sPassword) = True Then
MsgBox "Connection Successful", vbInformation, "ODBC Logon"
Else
MsgBox "Connection Failed", vbExclamation, "ODBC Logon"
End If
End Sub
Private Sub ShowSQLErrorInfo(hdbc As Long, iMSGIcon As Integer)
Dim iResult As Integer
Dim hstmt As Long
Dim sBuffer1 As String * 16, sBuffer2 As String * 255
Dim lNative As Long, iOutlen As Integer
sBuffer1 = String$(16, 0)
sBuffer2 = String$(256, 0)
' Do 'Cycle though all the Errors
iResult = SQLError(0, hdbc, hstmt, sBuffer1, lNative, sBuffer2, _
256, iOutlen)
If iResult = SQL_SUCCESS Then
If iOutlen = 0 Then
MsgBox "Error -- No error information available", _
iMSGIcon, "ODBC Logon"
Else
MsgBox Left$(sBuffer2, iOutlen), iMSGIcon, "ODBC Logon"
End If
End If
' Loop Until iResult <> SQL_SUCCESS
End Sub
where as my VC ++ program is
this program doesn't work
void main()
{
SQLHENV m_SQLEnvironment;
SQLHDBC m_SQLConnection;
SQLRETURN iReturn;
// Obtain Environment Handle
iReturn = SQLAllocEnv(&m_SQLEnvironment);
if (iReturn != SQL_SUCCESS)
printf("Error in Allocating Environment");
// Obtain Connection Handle
iReturn = SQLAllocConnect(m_SQLEnvironment,&m_SQLConnection);
if (iReturn != SQL_SUCCESS)
{
printf("Error");
iReturn = SQLFreeEnv(m_SQLEnvironment);
}
//Test Connect Parameters
iReturn = SQLConnect(m_SQLConnection,(SQLCHAR*)"OraTest",SQL_NTS,(SQLCHAR *)"scott",SQL_NTS,(SQLCHAR *)"tiger",SQL_NTS);
if (iReturn != SQL_SUCCESS)
{
if (iReturn == SQL_SUCCESS_WITH_INFO)
{
// 'The Connection has been successful, but SQLState Information
// 'has been returned
// 'Obtain all the SQLState Information
// If Check1.Value Then ShowSQLErrorInfo hdbc, vbInformation
// IsValidODBCLogin = True
printf("Connected");
}
else
{
// 'Obtain all the Error Information
// If Check1.Value Then ShowSQLErrorInfo hdbc, vbExclamation
// IsValidODBCLogin = False
printf("Failed Connecting");
}
}
else
{
//IsValidODBCLogin = True
printf("Connected");
}
//'Free Connection Handle and Environment Handle
iReturn = SQLFreeConnect(m_SQLConnection);
iReturn = SQLFreeEnv(m_SQLEnvironment);
}
can anyone figure out the problem.
its urgent
|
|
|
|
|
r u copying same code to VC?? if yes then of course it will give errors.
|
|
|
|
|
the VC++ program is attached under the VB program asked in the question
try that first and then answer please.
i understand that vb code doesn't work in vc
that is why i gave the vb and also the vc code attached.
|
|
|
|
|
You can't mix VB code and C++ code!
If it was possible... I would go to hell!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
vc code is also attached below the VB code
|
|
|
|
|
cant find WM_SETFOCUS for my dialog from class wizard for some reason.
I can find WM_KILLFOCUS however...?
it's a dialog application btw. Thanks
norm
|
|
|
|
|
Go to the last page of the wizard - there's a combo that lets you select which messages you want displayed. Set it to "window" and you should see all the messages.
Shog9
------
So they took me down to the gallows
And this boy, he said to me:
"Why do you smile, when the rope's around your neck?"
I said, "I tell you boy, when i get back..."
|
|
|
|
|
I've found it. I added two event handlers:
1. one for WM_SETFOCUS
2. one for WM_KILLFOCUS
My intention is that when my dialog application loses focus, the dialog will become more transparent. When the dialog gets focused, the dialog becomes more opaque.
But it seems that my dialog does not respond to the event WM_SETFOCUS and WM_KILLFOCUS for some reason. Are these two events for controls only? But from MSDN, it seems that these two messages are generic "windows" message. And a dialog is a window...?? And I dont want to use mouse leave event neither...
Thanks!
norm
|
|
|
|
|
Check out WM_ACTIVATE ...
Shog9
------
So they took me down to the gallows
And this boy, he said to me:
"Why do you smile, when the rope's around your neck?"
I said, "I tell you boy, when i get back..."
|
|
|
|
|