|
CreateDirectory(...); // in Windows SDK
INTP
|
|
|
|
|
if ( CreateDirectory("c:\\MyDir", NULL))
{
AfxMessageBox("Danielle Brina's directory created ");
}else
{
AfxMessageBox("Danielle Brina's directory creation failed ");
}
Wandered in, liked what I saw, and am here to stay!
What's your excuse?
|
|
|
|
|
Hope this Will help
SHFileOperation
Copies, moves, renames, or deletes a file system object.
int SHFileOperation(<br />
LPSHFILEOPSTRUCT lpFileOp<br />
);
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I'm writng an aplication which will blocks banners, popups, some scripts etc.
So I think I need to catch all HTTP traffic, change some parts of packets and put it back to user's program such as browser.
I tried to MSDN and Google but found only solutions how to capture packets with no way to change them.
|
|
|
|
|
It sounds like you'll need to make a proxy - i.e. an app that acts as a web proxy server, and modifies the http traffic that passes through it
Have a search for rewriting proxies, that might help
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
Most people will agree that macro should be as less frequently
as possible. However, I found that sometimes, macro increase
clearity.
#define Stack( type, next ) StackTemplate<type, (int)&(((type*)NULL)->next)>
So, what other choices do I have besides macro? Should I continue
to use macro in such situation?
Thanks
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
#define Stack( type, next ) StackTemplate<type, (int)&(((type*)NULL)->next)>
I'm curious.. what significance does the next parameter have? Could you not rewrite the templates instead?
--
Weiter, weiter, ins verderben.
Wir müssen leben bis wir sterben.
I blog too now[^]
|
|
|
|
|
Jörgen Sigvardsson wrote:
I'm curious.. what significance does the next parameter have?
That template specification is weird. It's assuming a structure something like this:
struct MyStruct
{
int member1;
int member2;
int next;
}; The 2nd template parameter in the #define will calculate the size of the structure up to (and not including) the next member, in this case the calculation will return 8. It seems that the structure was at one point used as a linked list, and this stack structure stores it as an array, therefore needing the size of the useful parts of the structure.
Jörgen Sigvardsson wrote:
Could you not rewrite the templates instead?
I would . Although I'd probably rewrite the structure without a next parameter so you can just use the sizeof operator on the type. Of course, the other way to do it is to use a default parameter for the second template parameter, defined as "(int)&(((type*)NULL)->next) "
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Who.. uuh, came up with this template? It's overly complex and kind of bizarre.
--
Weiter, weiter, ins verderben.
Wir müssen leben bis wir sterben.
I blog too now[^]
|
|
|
|
|
// Sample
// C/C++ macro: can not handle min(++n1,n2) or min(n1++,n2)
#define min(n1,n2) ((n1)<(n2)?(n1):(n2))
// min interger: inline equivalent with type checking
inline min(int n1,int n2) { return(n1<n2?n1:n2); }
SIMPLE STACK:
#include "mytype.h" // contains MyType class or structure
#include <stack> // standard C++ header (contains template)
typedef std::stack<MyType> MyStack;
// MyStack.push(...), MyStack.pop(...), MyStack.top(...), MyStack.top()
INTP
|
|
|
|
|
Okay, this is no simple stack class, this is the stack template class
that used in an advanced 3D application -- Doom 3. This is the source
from idsoftware. They used two macros here in a stack template.
idStack(type, next) and STACK_NEXT_PTR( element ) to simplify the
usage. Since many books suggest to avoid macro in C++, and now that
I'm looking at the code from idsoftware, I've been wondering if
there is a way to replace macro. How they used macro in the code
below seems very clever to me.
Note: The code is free and downloadable from idsoftware.
#define idStack( type, next ) idStackTemplate<type, (int)&(((type*)NULL)->next)>
template< class type, int nextOffset >
class idStackTemplate {
public:
idStackTemplate( void );
void Add( type *element );
type * Get( void );
private:
type * top;
type * bottom;
};
#define STACK_NEXT_PTR( element ) (*(type**)(((byte*)element)+nextOffset))
template< class type, int nextOffset >
idStackTemplate<type,nextOffset>::idStackTemplate( void ) {
top = bottom = NULL;
}
template< class type, int nextOffset >
void idStackTemplate<type,nextOffset>::Add( type *element ) {
STACK_NEXT_PTR(element) = top;
top = element;
if ( !bottom ) {
bottom = element;
}
}
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
Alex Ngai wrote:
How they used macro in the code below seems very clever to me.
It's nothing more than a hack. They've simply taken a C-based stack and made it into a template class, without actually converting it to C++. I don't recommend using it as an example of a good C++ stack. If it was a true C++ template-based stack, the second template parameter wouldn't even be necessary.
The std::stack class will be fine for your use.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Interesting code. Quite ugly. I can't understand what benefit they get from doing it this way, except that you have access to the 'next' pointer. It looks to me as though they either have some old C code they are wrapping with a nice template, or else this was written in the early days of templates.
Unless it's a really wierd data structure which has multiple stacks at once (ie, each element is part of several linked lists at the same time).
You would need to look at the larger context. To remove the macro, you would probably need to completely rewrite the data structure.
Although macros should be avoided if possible (and it's not *always* possible), it seems to me that in this case, the whole design is quite ugly, and the macro is the least of the problems. But without a good idea of how this class is actually used, I can't be sure. Maybe this bit of ugliness makes the overall program really elegant (and fast).
|
|
|
|
|
I need to post a message to a window representing the ALT+F key press
This window is a window of another app (not my own)
PostMessage works with signle keys
How Can I Till it that ALT is pressed
Thanks
Hany
|
|
|
|
|
Here is What MSDN says ABout your Problem
<br />
WM_CHAR<br />
The WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. The WM_CHAR message contains the character code of the key that was pressed. <br />
<br />
A window receives this message through its WindowProc function. <br />
<br />
LRESULT CALLBACK WindowProc(<br />
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);<br />
Parameters<br />
wParam <br />
Specifies the character code of the key. <br />
lParam <br />
Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. Value Description <br />
0–15 Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative. <br />
16–23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM). <br />
24 Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0. <br />
25–28 Reserved; do not use. <br />
29 Specifies the context code. The value is 1 if the ALT key is held down while the key is pressed; otherwise, the value is 0. <br />
30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up. <br />
31 Specifies the transition state. The value is 1 if the key is being released, or it is 0 if the key is being pressed. <br />
<br />
<br />
Return Values<br />
An application should return zero if it processes this message. <br />
<br />
Remarks<br />
The WM_CHAR message uses UTF-16. <br />
<br />
Because there is not necessarily a one-to-one correspondence between keys pressed and character messages generated, the information in the high-order word of the lParam parameter is generally not useful to applications. The information in the high-order word applies only to the most recent WM_KEYDOWN message that precedes the posting of the WM_CHAR message. <br />
<br />
For enhanced 101- and 102-key keyboards, extended keys are the right ALT and the right CTRL keys on the main section of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN and arrow keys in the clusters to the left of the numeric keypad; and the divide (/) and ENTER keys in the numeric keypad. Some other keyboards may support the extended-key bit in the lParam parameter<br />
<br />
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Post WM_KEYDOWN message of VK_ALT to simulate holding that key down, then post the WM_KEYDOWN for the 'F' key, then post WM_KEYUP messages for
the same.
There is no spoon.
suhredayan
|
|
|
|
|
I made a COM (dll) server, i hope it will work in the local
network as a DCOM , because i haven't tried it yet. So it
is three tier Database Architecture, the client programm
sends a query to the server programm ant it sends a CSV
formated data.
The first question - i tried to use ADO (_Recordset) - as
return parameter, but had error in the IDL file, i didn't
know how to avoid it, and i changed it to IUnknow, but in
the client programm i couldn't dispatch it: i did this:
In The Client:
_Recordset* pRecordset = pDatabase->GetMaterials();
ANd it ruturns 0 = WHY???
In The Server:
GetMaterials(IUnknown* pRecordset)
{
_RecordsetPtr p(__uuidof(_Recorset))
//Some Query Procedure
//And in the finish
_RecordsetPtr->QueryInterface(__uuidof(_Recordset),(void**)
&pRecordset);
return S_OK;
}
And Another Question.
Server Should be able to change the address of Database.
For example now = the addres is C:\econ.mdb;
but if the database in other place?
I tried to use GetModulFileName() - but it returned -
C:\Windows\System32\Svchost.dll.
The Main question is - how to find out where my dll
placed...
Thanks.
|
|
|
|
|
hey,
How to make a slider control's thumb moverment freeflow. Currently the slider thumb taking fixed range jumps to reach the clicked channel position. I need the thumb posion in the clicked region with in a single jump. pls help me.
Thanks in advance
shijuck
|
|
|
|
|
ok i am very new to working with dll files and just recently got a dll to compile and a program to compile and use the dll file.
i made a program to test my dll, in my dll i got functions defined that have variables defined that are returned and than used in another function in the same dll file. what i was wondering was how i can return those variables and get them to be used cause after i got through first function the program crashes.
not sure if its something to do with how i return the variables or not, if someone could help i would really appreciate it.
the more you learn the less you know, no one is truely a master. cause the more you seek to be the master the less of a master you become.
|
|
|
|
|
hey,
just came across this. don't know if you've figured it out yet but I'll help you out anyway.
Its hard for me to tell what is causing the problem without seeing some code, so I'll just give you a quick rundown of what you should be doing to make it run correctly. Some of this probably is obvious but I'll say it anyway.
Make sure every function in the dll that you are going to use has the dll export and import statements in your dll and main app. Secondly, for what you are saying, this is how it should work.
In the main application
temp variable = 1st dll function();
2nd dll function(temp variable);
That's all there is to it.
|
|
|
|
|
Hello,
I've built an app with the web browser component and print using ExecWB and the DONTPROMPTUSER option.
This works most of the time, but occasionally the print dialog does appear (say 1 in every 50 prints) This causes huge problems for my mouse-free operators.
Below is the code, problem occurs on Win XP.
hr = m_pBrowser->ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, &vArg, NULL);
Any ideas? This has me baffled?
Joanne
|
|
|
|
|
I had a weird problem just recently where: ExecWB( OLECMDID_PASTE, OLECMDEXECOPT_DODEFAULT, NULL, NULL ); didn't work on one users PC. I changed it to use the newer code in MFC7 afxhtml70.h and it solved the problem. This is in Surfulater (see sig).
I have no idea if this is related but I'd suggest trying the MFC7 CHtmlEditCtrlBase::PrintDocument().
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
What's in the vArg ? If it is not initialized properly, it may trigger some "prompt user" behavior. If it's not initialized explicitly, its contents will be random, which reflects your application's random behavior.
--
Weiter, weiter, ins verderben.
Wir müssen leben bis wir sterben.
I blog too now[^]
|
|
|
|
|
Thanks for the replies.
I am using the vArg to clear the header and footer so that the default Internet Explorer text does not appear on my printout.
It was a while ago, but I think this I got the code from a Codeproject article. Does it look ok to you?
I can't disable it to see if the problem goes away because its on a live manufacturing system and the problem never happens for me (of course)
Joanne
SAFEARRAYBOUND psabBounds[1];
SAFEARRAY *psaHeadFoot;
// Initialize header and footer parameters to send to ExecWB().
psabBounds[0].lLbound = 0;
psabBounds[0].cElements = 2;
psaHeadFoot = SafeArrayCreate(VT_VARIANT, 1, psabBounds);
VARIANT vHeadStr, vFootStr;
VariantInit(&vHeadStr);
VariantInit(&vFootStr);
// Argument 1: Header
vHeadStr.vt = VT_BSTR;
vHeadStr.bstrVal = SysAllocString(L"");
// Argument 2: Footer
vFootStr.vt = VT_BSTR;
vFootStr.bstrVal = SysAllocString(L"");
// SAFEARRAY must be passed ByRef
VARIANT vArg;
VariantInit(&vArg);
vArg.vt = VT_ARRAY | VT_BYREF;
vArg.parray = psaHeadFoot;
LONG rgIndices = 0;
SafeArrayPutElement(psaHeadFoot, &rgIndices, static_cast<void *="">(&vHeadStr));
rgIndices = 1;
SafeArrayPutElement(psaHeadFoot, &rgIndices, static_cast<void *="">(&vFootStr));
|
|
|
|
|
Setting the background color in response to WM_CTLCOLORBTN appears to have no effect because if you're not running a theme-aware OS, or running a theme-aware OS in classic mode, the button face covers the entire client area, so no background shows through. If you run XP in the default theme, the button has rounded corners, so a bit of the background will be visible.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
|
|
|
|
|