|
i'd like to convert between a char and int!
from CString.GetAt(int) i get a char ( or unsigned short) how do i change this to an integer (to get the ASCI code)???????
Please help
|
|
|
|
|
int iInt = 127;
char cChar = 99;
char cCast = static_cast<char>(iInt);
int iCast = static_cast<int>(cChar);
Normski. - Professional Windows Programmer
|
|
|
|
|
HTML parser ate some stuff:
int iInt = 127;
char cChar = 99;
char cCast = static_cast <char>(iInt);
int iCast = static_cast <int>(cChar);
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Cheers Tim,
I don't much web stuff.
Normski. - Professional Windows Programmer
|
|
|
|
|
Cheers Tim,
I don't do much web stuff.
Normski. - Professional Windows Programmer
|
|
|
|
|
Does anyone know how to get the system idle time???
Thanx in advance
Bin
|
|
|
|
|
Why do you care about the system idle time?
I have to think you're really trying to do something else, like calculate uptime or something. What are you trying to do?
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
Now for the c++ dll that will object pool db connection and return a disconnected recordset, I have been attempting to learn on my own with a lot of samples.
The project works fine I believe. Let´s say it runs and I can watch its specifics in the MMC (View Status, Components)
I have run this with and without the IObjectControl Method. I know I have not coded it 100%.
The sample that I am using did not include the events Activate, Deactivate, CanBePooled, it would still object pool (allow me to create instances), but I read:
It is not mandatory for a COM object to implement this interface in order to be pooled. The exception to this rule is if the pooled object also happens to be transactional, in which case the CanBePooled method of the interface is used to determine the state of the resources it holds. If a COM object does not implement IObjectControl, instances of it will be created until the maximum pool size is reached, as each instance is assumed to be poolable.
To see the related changes, you must open the project (Activate, Deactivate, CanBePooled Methods.)
I know that I am not handling the activate, deactivate, canbepooled correctly could you take a look at this part.
I am not evening deactivating the existing code handled it in its own way.
HERE IS A SAMPLE OF WHAT I AM TALKING ABOUT Alan Gordon was the original author of this)
// Book.cpp : Implementation of CBook
#include "stdafx.h"
#include "Articleproject.h"
#include "Book.h"
const E_CONFIGURATION=MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,0x200+108);
const E_CONFLICTS_FOUND=MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,0x200+109);
const int conTitleFieldLength=80;
#undef EOF
/////////////////////////////////////////////////////////////////////////////
// CBook
HRESULT CBook::Activate()
{
HRESULT hr = GetObjectContext(&m_spObjectContext);
if (SUCCEEDED(hr))
return S_OK;
return hr;
}
BOOL CBook::CanBePooled()
{
return TRUE;
}
void CBook::Deactivate()
{
m_spObjectContext.Release();
}
STDMETHODIMP CBook::InterfaceSupportsErrorInfo(REFIID riid)
{
static const IID* arr[] =
{
&IID_IBook
};
for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
{
if (::ATL::InlineIsEqualGUID(*arr,riid)) // pjs added
return S_OK;
}
return S_FALSE;
}
STDMETHODIMP CBook::RetrieveByID(BSTR id, _Recordset **rs)
{
_bstr_t strDescription;
HRESULT hRetval;
_ConnectionPtr pConn;
_RecordsetPtr pRS;
IContextState *pContextState=NULL;
if (0==mConnectionString.length())
{
hRetval=E_CONFIGURATION;
strDescription=L"You must configure a connection string";
goto exit_cleanup;
}
hRetval=CoGetObjectContext(IID_IContextState,(void **)&pContextState);
if (SUCCEEDED(hRetval))
{
// NEW WAY PJS 12/8/2001 TO PASS IN SQL STMT AND CREATE AN DISCONN RECORDSET
_bstr_t sql(id);
try
{
// Create and Open the Connection PJS
pConn.CreateInstance( __uuidof(Connection));
pConn->Open(mConnectionString, "", "",-1);
// Create and Open the Recordset PJS
pRS.CreateInstance( __uuidof(Recordset));
pRS->CursorLocation=adUseClient;
pRS->Open(sql,pConn.GetInterfacePtr(),adOpenStatic,adLockBatchOptimistic,-1);
pRS->AddRef();
*rs=pRS;
pRS->PutRefActiveConnection(NULL);
}
catch ( _com_error err)
{
strDescription=err.Description();
hRetval=err.Error();
}
}
else
{
_com_error err(hRetval);
strDescription=
L"Your component may not be" \
L" configured";
}
// Exit and cleanup code
exit_cleanup:
if (NULL != pContextState)
{
if (SUCCEEDED(hRetval))
pContextState->SetMyTransactionVote(TxCommit);
else
pContextState->SetMyTransactionVote(TxAbort);
pContextState->SetDeactivateOnReturn(VARIANT_TRUE);
pContextState->Release();
}
if (NULL != pConn)
{
if (adStateOpen==pConn->GetState())
pConn->Close();
pConn=NULL;
}
if (SUCCEEDED(hRetval))
return hRetval;
else
return Error((LPOLESTR)strDescription,IID_IBook,hRetval);
}
Other changes:
I changed compile info in comsvcs.h
I forced compile to be for win2k. I was getting weird _GetObjectContext errors.
I found on Google an article that told be to force to 2K. What are your thoughts ???
After implementing I was able LINK just fine. I read there is some issue with how win2k platform is identified. ??
//#if (_WIN32_WINNT >= 0x0500)
#define GetObjectContext(ppIOC) (CoGetObjectContext(IID_IObjectContext, (void **) (ppIOC)) == S_OK ? S_OK : CONTEXT_E_NOCONTEXT)
//#else
//extern HRESULT __cdecl GetObjectContext (IObjectContext** ppInstanceContext);
//#endif
3. Provider = MSDAORA.1;Password=wwww;User ID=xxxxx;Data Source=DEV2;Persist Security Info = True;OLE DB SERVICES = -2;
I put a value of OLE DB SERVICES = -2 at the end of my OLEDB Connect string.
Is this the best number to use. I want to just ensure that we are object pooling not resource pooling. I did not wish to use 0 "no services". What are your thoughts?
|
|
|
|
|
I tried to get the info about a button of a CToolBar object using the following code. Everything works if the CToolBar onject is in the same app that the following code belongs. When used for a CToolBar object of another app, GetButtonCount() still works, but not GetButton(). Does anybody knows why and is there a solution?
Thanks,
Wally
-------------------
void CTryBarDlg::OnGetToolbarInfo()
{
// TODO: Add your control notification handler code here
int nToolBarHandle;
int nCount;
CToolBar *pToolBar;
CToolBarCtrl *pToolBarCtrl;
TBBUTTON tbButton;
// read tool bar handle from UI, obtaine dusing SPY++ before hand
UpdateData(true);
sscanf(m_sToolBarHandle, "%i", &nToolBarHandle);
// get a CToolBar object from the HWND of the toolBar
pToolBar = (CToolBar*)CWnd::FromHandle((HWND)nToolBarHandle);
// get CtoolBarCtrl object fromt the CTolBar object
pToolBarCtrl = &pToolBar->GetToolBarCtrl();
// get tool bar info from the CToolBarCtrl object
// !! working
nCount = pToolBarCtrl->GetButtonCount();
// get button info from the CToolBarCtrl object
// !! not working
memset(&tbButton, 0, sizeof(TBBUTTON) );
pToolBarCtrl->GetButton(1, &tbButton);
}
-------------------
|
|
|
|
|
Does anybody know how to resize a tab control dynamicly?
|
|
|
|
|
SetWindowPos()??
---
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
I having a strange problem in an OpenGL data visualization project I am working on. My display scene has two alpha-blended planes above an opaque object. The upper plane has an alpha level of 0.8 and lower one is at 0.4. It works really well. Most of the time.
Here is where the weirdness comes in. I have tried this on a older Matrox card, a laptop with an ATI chip, a TNT2, a GF2 MX, and a GF3. It works great everywhere except for on the GF2 MX. I have even tried two versions of GF2 MX cards : an older one and a new MX 400. I have even tried the last two driver revs, 21.93 and 23.11. It also works fine in SW rendering mode on all cards.
What I am seeing is tearing where the lower translucent plane is showing through the upper plane in broad stripes when the object is zoomed far away from the camera.
Does anyone know of a work-around for this ?
|
|
|
|
|
I fixed the problem. I switched the order that the two planes are being drawn and it works just fine now.
I still think it is really weird that this problem only shows up on one kind of card. Oh well.
|
|
|
|
|
I've added an XML manifest to one of my programs so that dialog box controls are painted using the new Windows XP visual style. This works just fine. But, the program's toolbars don't get repainted properly. I am using the flat style with gripper, and the gripper doesn't appear correctly.
Has anybody figured out a solution to this problem? Does anybody know if it will be fixed in a service pack?
|
|
|
|
|
I'm loading font from the file( it's not binary image, but grayscale) So I'm building lists so I can dispaly messages with the font. If I disable blending, message is in the black square, but wiht blending I don't get a desired color. Is there a way to setup blanding so I'd get what I want? Thanks
Regards, Alexander.
|
|
|
|
|
NeHe's site has excellent OpenGL tutorials. One of which is on masking.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Thanks, it does work! And I'm wondering if I need a negative image of the font and I have to create lists with negative letters, maybe there's the way to do it with only one set of lists? Or at least how can I invert an image in my program? I mean a neat way to do it?
|
|
|
|
|
I'm sorry, I really don't know. I've not found time to actually *do* the NeHe tutorials....
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
It's ok, thanks for help, anyway it does work ))
|
|
|
|
|
Hi all, I have a CListCtrl that contains some only-text item, I want to move(pressing a button) the selected item up/down in the list but how?
I have to use "SetItemPosition"? There wasn't a method to move the item of only one position?
Help me please, and sorry for my english!
Thanks.
|
|
|
|
|
When you are in Report mode, something like this SwapRows function should help:
void CMyListCtrl::SwapRows(int row1, int row2)
{
// rowText will hold all column text for one row
CStringArray rowText;
LV_ITEM lvitemrow1, lvitemrow2;
int nColCount = GetColumnCount();
rowText.SetSize( nColCount );
int i;
for( i=0; i < nColCount; i++)
rowText[i] = GetItemText(row1, i);
lvitemrow1.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
lvitemrow1.iItem = row1;
lvitemrow1.iSubItem = 0;
lvitemrow1.stateMask = LVIS_CUT | LVIS_DROPHILITED |
LVIS_FOCUSED | LVIS_SELECTED |
LVIS_OVERLAYMASK | LVIS_STATEIMAGEMASK;
lvitemrow2 = lvitemrow1;
lvitemrow2.iItem = row2;
GetItem( &lvitemrow1 );
GetItem( &lvitemrow2 );
for( i=0; i< nColCount; i++)
SetItemText(row1, i, GetItemText(row2, i) );
lvitemrow2.iItem = row1;
SetItem( &lvitemrow2 );
for( i=0; i< nColCount; i++)
SetItemText(row2, i, rowText[i]);
lvitemrow1.iItem = row2;
SetItem( &lvitemrow1 );
}
WM_HOPEITHELPED
|
|
|
|
|
Thank you all for your help with my CreateProcess question. WaitForSingleObject was just what I was looking for!
Now I have just one more question for you. How can I wait for the process - and all processes it creates - complete? I am guessing I must somehow check the process periodically to see if it has any children, and then possibly use WaitForSingleObject on them? Any help would be nice, especially if you can explain how or why to do something (hey, I'm still learning).
Cheers,
Russell McCurly
Hobbiest Programmer
|
|
|
|
|
I'm assuming you are looking for a general solution. e.g. any process with any children, not something you wrote yourself or have access to the source for.
If the process you launched waits for its child processes, you don't need to do anything more than wait for it.
I don't know how to check a process for children. But, even if there is one, I don't think you can rely on it. Here is one of the creation flags available to create process:
CREATE_NEW_PROCESS_GROUP
Here's its description from MSDN:
The new process is the root process of a new process group. The process group includes all processes that are descendants of this root process. The process identifier of the new process group is the same as the process identifier, which is returned in the lpProcessInformation parameter. Process groups are used by the GenerateConsoleCtrlEvent function to enable sending a CTRL+C or CTRL+BREAK signal to a group of console processes
Hope this helps,
Bill
|
|
|
|
|
Thank you for the reply. I have tried various different ways of calling CreateProcess, including CREATE_NEW_PROCESS_GROUP as you suggested, and other flags and non-nulled parameters that mentioned some kind of inheritance, but WaitForSingleObject still say's it returns when the first process ends (rather than it's children).
Have you any further ideas?
Cheers,
Russell McCurly
Hobbiest Programmer
|
|
|
|
|
Hi, I have a string of RGB RGB RGB RGB bytes that makes up a image, and I'd like to display it onto the screen. Can someone please give me the road map for doing that? It's kinda confusing for someone w/ minium graphical background. Here's what I wanted to do:
1. Put the RGBRGBRGBRGB string into a CBitmap
2. Display the CBitmap onto my screenDC (where screen may have any color bit depth -32bit 24bits 16bits...)
My CBitmap image only displays properly when my monitor is set to 32bit/pixel. I believe I need to use DIB for these various bit depth compatability.
THANKS IN ADVANCE!
|
|
|
|