|
if you wanna program for win32 application you must drive to functions itself.
1)WinMain 2)WinPorc
try this code :(thanks for Ivor Horton Books. you can download source code & see chapter 7 )
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
WNDCLASS WindowClass;
<br />
static char szAppName[] = "OFWin";
HWND hWnd;
MSG msg;
<br />
WindowClass.style = CS_HREDRAW | CS_VREDRAW;<br />
<br />
WindowClass.lpfnWndProc = WindowProc;<br />
<br />
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
<br />
WindowClass.hInstance = hInstance;
<br />
WindowClass.hIcon = LoadIcon(0, IDI_APPLICATION);<br />
<br />
WindowClass.hCursor = LoadCursor(0, IDC_ARROW);<br />
<br />
WindowClass.hbrBackground = static_cast<HBRUSH>(GetStockObject(GRAY_BRUSH));<br />
<br />
WindowClass.lpszMenuName = 0;
<br />
WindowClass.lpszClassName = szAppName;
<br />
RegisterClass(&WindowClass);<br />
<br />
hWnd = CreateWindow(<br />
szAppName,
"A Basic Window the Hard Way",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
0,
0,
hInstance,
0
);<br />
<br />
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
<br />
while(GetMessage(&msg, 0, 0, 0) == TRUE)
{<br />
TranslateMessage(&msg);
DispatchMessage(&msg);
}<br />
<br />
return msg.wParam;
}<br />
<br />
<br />
long WINAPI WindowProc(HWND hWnd, UINT message, WPARAM wParam,<br />
LPARAM lParam)<br />
{<br />
HDC hDC;
PAINTSTRUCT PaintSt;
RECT aRect;
<br />
switch(message)
{<br />
case WM_PAINT:
hDC = BeginPaint(hWnd, &PaintSt);
<br />
GetClientRect(hWnd, &aRect);<br />
<br />
SetBkMode(hDC, TRANSPARENT);
<br />
DrawText(<br />
hDC,
"But, soft! What light through yonder window breaks?",<br />
-1,
&aRect,
DT_SINGLELINE|
DT_CENTER|
DT_VCENTER);
<br />
EndPaint(hWnd, &PaintSt);
return 0;<br />
<br />
case WM_DESTROY:
PostQuitMessage(0);<br />
return 0;<br />
<br />
default:
return DefWindowProc(hWnd, message, wParam, lParam);<br />
}<br />
}<br />
<br />
|
|
|
|
|
Drag and Drop Operations between list ctrl and tree ctrl (operations like windows explorer)
please help me
ram
|
|
|
|
|
handle HDN_BEGINDRAG,HDNBEGINTRACK,........
|
|
|
|
|
Hi
check out CDragDropTreeCtrl class. I am sure i downloaded it from code project in first place. It make drag drop very easy to implement if you just look at the code for few minutes, you can implement same drag and drop in list ctrl with very small changes.
If that does not help let me know, if i get time to create a drag drop list control for the tree, i will post it.
|
|
|
|
|
here[^] maybe it is some helpful to you
|
|
|
|
|
I have a CDialog class in a VC++ dialog application that works well. Now I want to use that CDialog class in a single document application. I know I can cut and paste, but is there a more elegant way to use this CDialog in a single document application. (This is a learning experience rather than a production effort. The next step will be to use it in a multiple document application.)
|
|
|
|
|
The type of application matter very little, if at all, for a dialog. The dialog should be able to work with an SDI, MDI, or non-document app.
About the best you could (in terms of elegance) is to place the dialog and its resources in a DLL then you will have just one instance of it. Otherwise, copying the files is what you'll have to do.
|
|
|
|
|
i did not find CBitmapButton Class in the class wizard
what went wrong
please help me
ram
|
|
|
|
|
if you using VS2003 and you need to CBitmapButton its exist in MFC Class Wizard its above CButton.
|
|
|
|
|
Hi All.
I try to create some dialog in some multiThread application.
The dialog need to be modeless and i cant crate it .
this is the code that fail
CMyDialog *dlg = new CMyDialog;
dlg->Create(CMyDialog::IDD);
dlg->ShowWindow(1);
The fail is in the ShowWindow function --> i check with debug and i found that after Create function i got (CDialog::Hwnd = 0).
How do i do it ??
Thanks for any help.
|
|
|
|
|
Does this code works or not
<br />
CChild *dlg;<br />
dlg = new CChild();<br />
dlg->ShowWindow(SW_SHOW);<br />
-----------------------------<br />
IMPLEMENT_DYNAMIC(CChild, CDialog)<br />
CChild::CChild(CWnd* pParent )<br />
: CDialog(CChild::IDD, pParent)<br />
{<br />
Create(IDD);<br />
}<br />
|
|
|
|
|
What you wrote is not working.
|
|
|
|
|
Did you try it and whats return value of Create?
|
|
|
|
|
why not use SW_SHOW as argument to ShowWindow? Anyway, is your dialog can work as Modal one? Maybe you have problems with custom controls (in this case dialog will not work as modal one also).
|
|
|
|
|
doModel work fine -
There is not control on this dialog - this is just for train and learnning ...
|
|
|
|
|
i think because Create return result immediately after displaying dialog box.
so if you wrote CMydialog dlg; because you create in stack when get out of scope
dialog displayed for mere millisecond and then disapear!!!!!!!because desctructor is call!!!!
but you create in heap ! in heap i think some error such that occur! when you create in heap in some function when get out of scope cause that you lost address!!!!!!!!!(is that right?????)
so if you one that you dialog show in screen add these code:
after
dlg->ShowWindow(1);
add:
while(1);
i think you can see you dialog!!!!!!!!!!!
but the solution for this!
it is better that you create youu CMydialog instance some where else such as
constructor of your class such as *Dlg class..... .
it is not necessary to create in heap!
|
|
|
|
|
i think because Create return result immediately after displaying dialog box.
so if you wrote CMydialog dlg; because you create in stack when get out of scope
dialog displayed for mere millisecond and then disapear!!!!!!!because desctructor is call!!!!
but you create in heap ! in heap i think some error such that occur! when you create in heap in some function when get out of scope cause that you lost address!!!!!!!!!(is that right?????)
so if you one that you dialog show in screen add these code:
after
dlg->ShowWindow(1);
add:
while(1);
i think you can see your dialog!!!!!!!!!!!
but the solution for this!
it is better that you create youu CMydialog instance some where else such as
constructor of your class such as *Dlg class..... .
it is not necessary to create in heap!
|
|
|
|
|
Check your return values. Create() is failing.
|
|
|
|
|
HANDLE h;
CEOID oidCallLog = (CEOID) pItemArray->rgRefs[0].pRef;
hr =PhoneOpenCallLog(&h);
CHR(hr);
CEOID re;
hr=PhoneSeekCallLog(h,CALLLOGSEEK_END,0,&re); //finding the ref of last record
CHR(hr);
DWORD i,pp;
CALLLOGENTRY pCall[150]; //limited to 150 entries
for (i=0;i<re;i++){
hr=PhoneSeekCallLog(h, CALLLOGSEEK_BEGINNING,i,&pp);
CHR(hr);
pCall[i].cbSize=sizeof(CALLLOGENTRY);
hr=PhoneGetCallLogEntry(h,&pCall[i]);
CHR(hr);
}
//testing now
__int32 temp;
oidCallLog=(CEOID)pCall[0]; //here i'm testing
temp=oidCallLog;
wchar_t buffer[64];
_itow(temp,buffer,10);
::MessageBox(GetActiveWindow(),buffer,TEXT("test"),MB_OK);
////////////// The result is really different when i check the value of oidCallLog ?????????????!!?!?!?!
-----------------------------------------------------------------
hi all,
i'm trying to add a new menu extension for call history.
i used everything based on Inbox menu extension sample in WM2005 sdk
evertything works great,except i dont know how to relate the Object id (oidCallLog) which i'm getting from the context menu,with the actualy call log entry.
i mean,pCall[i] has the call log. how to extract an object id from it which would be really same as the one i'm getting from pItemArray, so i know exactly this is the call log i'm selecting with context menu.
i hope i made it clear enough
Thankx alot in advance
|
|
|
|
|
hi every VC programmer, i have a math problem with my coding.
here is the sample:
#define NDIG 32 /* assume max no. of digits */
int getnum(void);
main(){
int val, i, count;
char chars[NDIG];
i = getnum();
/* print in binary */
val = i;
count = 0;
do{
//val = val / 2;
chars[count] = val % 2;
val = val / 2;
count = count + 1;
}while(val);
count = count - 1; ******(I wonder what this means?)*****
while(count >= 0){
printf("%d", chars[count]);
count = count - 1;
}
printf("\n")
}
getnum(){
int c, value;;
value = 0;
c = getchar();
while(c != '\n'){
value = 10*value + c - '0';
c = getchar();
}
return (value);
}
i hope you will reply this. Thanks
~~~@@@###EZRA###@@@~~~
|
|
|
|
|
can u be more specific?
count=count - 1
means whatever was in count decrement it by 1
same as count--
is that ur question?
|
|
|
|
|
oops sorry ok it is my mistake.
my question is why count = count - 1 need to be added to the sample example.
if so, can you explain how to convert string to binary step by step in this coding.
Thanks
i am trying to figure out this puzzled code line.
~~~@@@###EZRA###@@@~~~
|
|
|
|
|
The -1 is because it was incremented just prior to bailing out of the loop so that puts it back to where it should be.
For generating binary strings I usually use a bitmasking scheme. Something like this :
void GenBinaryString( BYTE byte, CString &str )
{
str = _T( "" );
const int bytebits = 8;
BYTE mask = 1 << ( bytebits - 1 );
for( int x = 0; x < bytebits; x++, mask >>= 1 )
{
str += ( mask & byte ) ? _T( "1" ) : _T( "0" );
if( x == 3 )
str += _T( " " );
}
}
|
|
|
|
|
Thanks
but your coding look more complicating to me.. T_T
Can you explain this clearly with comments per line? If cannot,
never mind, i will slowly learning.
~~~@@@###EZRA###@@@~~~
|
|
|
|
|
Shouldn't the compiler call the method in the base class when the method with the same name is not declared as virtual?
Is this specific to VS2003?
#include <iostream>
using namespace std;
class mammal
{
public:
void walk () {cout << "mammal walks" << endl;}
protected:
mammal (bool pFacialhair) {facialhair = pFacialhair;};
bool facialhair;
virtual void takesaleak () {cout << "mammal takes a leak" << endl;}
};
class dog : public mammal
{
private:
bool takingapiss;
public:
dog() : mammal(true)
{
facialhair = true;
};
int legs;
void walk () {cout << "dog walks" << endl;}
void takesaleak () {cout << "dog takes a leak" << endl;}
};
void main ()
{ dog Fido;
Fido.walk(); //Error: mammal walks Actually the output is: dog walks
Fido.takesaleak(); //dog takes a leak
//Fido.takingapiss; // not allowed because it is a protected method
}
Error!
Jon
|
|
|
|