|
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..."
|
|
|
|
|
yes, someone from CodeGuru already suggested to me to use WM_ACTIVATE (get focused), but what about WM_DEACTIVATE (lose focused)?
norm
|
|
|
|
|
Ok. First, the window that has focus and the active window are two different (though related) things, at least on Windows. Second, WM_ACTIVATE gets sent to both the window being activated and the window being deactivated; a flag is passed along with it to allow them to distinguish which is which. See MSDN for details...
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..."
|
|
|
|
|
thanks! i was silly enuf to spend all the time looking for WM_DEACTIVATE while WM_ACTIVATE is dispatched under both circumstances...
anyway, thanks, it's working now.
norm
|
|
|
|
|
Shog9 wrote:
a flag is passed along with it to allow them to distinguish which is which.
Gawd, I'm such a dork for not reading the manual ... I've been doing a lot of junk code just to do this !
Thanks!
Max.
|
|
|
|
|
how can u remove your application from taskbar?
thanks
norm
|
|
|
|
|
|
trying to draw on top of a button
CRect * prtExit = NULL;
CDC * pExitDC = NULL;
CWnd * pbtnExit = this->GetWindow(IDC_EXIT);
pExitDC = pbtnExit->GetDC();
pbtnExit->GetClientRect(prtExit);
pExitDC->TextOut( prtExit->left+5, prtExit->top+5, "Testing");
//I understand we dont need to text out and there's simpler way to do this, but I am just testing to see if I have control over the device context of a button. I was going to load a bitmap (I also know about BM_SETIMAGE...)
Anyway, the code crashed: "The memory could not be read".
By the way, this is done in dialog class constructor... is it possible that the button has not been constructed yet...?
norm
|
|
|
|
|
just tried to render a bitmap on face of a button, crashed the very same way: memory access:
HBITMAP h_bmpExit = NULL;
h_bmpExit = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), "./res/StopButton.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
if(h_bmpExit==NULL)
{
//Additional error handling here!
}
pbtnExit->PostMessage(BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) (HANDLE) h_bmpExit);
norm
|
|
|
|
|
|
I want to use SetLayeredWindowAttributes(...), I looked it up from MSDN and here's what I need:
1. Header Declared in Winuser.h, include Windows.h
2. Import library User32.lib
3. Minimum operating systems Included in Windows 95, Windows NT 3.1
(QUESTION 1) How can I "import" a library? I already tried "Add To Project>Files", it didnt work?
(QUESTION 2) it seems like Intellisense doesnt know about SetLayeredWindowAttributes()
Thanks!
URL to MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/SetLayeredWindowAttributes.asp
Link to code project article: http://www.codeproject.com/win32/Quaker1.asp?print=true
norm
|
|
|
|
|
norm wrote:
QUESTION 1) How can I "import" a library? I already tried "Add To Project>Files", it didnt work?
Nope - you go to the project settings and add it as an additional library, or include the directory it's in into your library paths. The version you have should be linking already, and if you can't see it, chances are you need a newer SDK, although you shouldn't if it comes with W95.
norm wrote:
QUESTION 2) it seems like Intellisense doesnt know about SetLayeredWindowAttributes()
Intellisense without Visual Assist is useless. Much as I hate to promote them since they want to charge me for moving to .NET, their product under VC6 is still indispensable.
It's also my recollection that this function is useless - which is why you don't see translucent windows on systems less than W2000, where it's supported nicely.
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
|
|
|
|
|
sorry, I tried to look for a place where i can specify imports under project setting, but not with much luck.
can u be a bit more specific about how to import a library?
norm
|
|
|
|
|
I just got this and see it was answered in the meantime.
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
|
|
|
|
|
SetLayeredWindowAttributes is only supported on Windows 2000 or greater therefore you will not see it on an older operating system. If you are building for windows 2000 or greater, you will need to define _WIN32_WINNT = 0x0500, otherwise the preproocessor will remove all of the API definitions that are only available on Windows 2000 and above. Coincidentally this will cause runtime error if you run one of these programs on a system that has an older DLL version.
As far as linking a library to your project, you can do it the way that you specified, or you can go to the linker tab of your projects settings, and add the name of the lib to your project. However most likely you are already linking user32.lib into your program if your program already has a user interface.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|